silverstripe-australia/silverstripe-partial-themes

一个模块,允许开发者仅针对基础主题模板定义一个或几个模板覆盖,应用于网站的子树部分

1.0.0 2015-07-16 03:56 UTC

This package is auto-updated.

Last update: 2024-08-29 04:25:21 UTC


README

一个用于更灵活管理主题的模块;通过将主题应用于网站的子树,通过指定组成“主题”的部分模板集,并通过允许将代码绑定到主题实现。

部分主题

允许创建可能仅覆盖“主”主题一部分的主题。例如,假设你将 /themes/simple 绑定为主项目主题,你可以在旁边指定另一个主题,仅更改一个模板。所以如果你想要创建另一个主题,例如 /themes/simplesimon,它仅在产品显示方式上有所不同,而不是指定一个全新的主题,你只需提供所需的模板。

/themes/simple
/themes/simple/templates
/themes/simple/templates/Includes
/themes/simple/templates/Includes/Footer.ss
/themes/simple/templates/Includes/SideBar.ss
/themes/simple/templates/Includes/Navigation.ss
/themes/simple/templates/Includes/SidebarMenu.ss
/themes/simple/templates/Includes/Header.ss
/themes/simple/templates/Includes/BreadCrumbs.ss
/themes/simple/templates/Page.ss
/themes/simple/templates/Layout
/themes/simple/templates/Layout/ProductPage.ss
/themes/simple/templates/Layout/Page_results.ss
/themes/simple/templates/Layout/Page.ss
/themes/simplesimon/templates/Layout/ProductPage.ss

然后,在CMS中,“部分主题”设置字段将设置为“simplesimon”。

主题助手

而不是在页面控制器初始化方法中指定特定于主题的代码,该模块会在初始化之前和之后寻找一个 {ThemeName}Helper 类来调用。

配置


Page:
  extensions:
    - PartialThemesExtension

Controller:
  extensions:
    - PartialThemesExtension

项目特定要求

你必须为将使用部分主题的控制器(特别是 Page_Controller 类)定义以下内容:

    public function getViewer($action) {
        $viewer = parent::getViewer($action);
        $viewer = $this->overridePartialTemplates($viewer, array(), $action);
        return $viewer;
    }

使用方法

一旦启用,主题设置将可在页面设置选项卡中找到。