collective.xdv和多个主题文件

时间:2011-04-12 10:42:15

标签: themes plone xdv

我为不同的网站部分提供不同的主题HTML文件。根据页面是首页还是某个子部分,存在一些主要的布局差异。

据我所知,默认行为只是拥有一个HTML文件:

http://pypi.python.org/pypi/collective.xdv#usage

使用多个主题文件,轻微规则变体和collective.xdv的最佳策略是什么?

Plone 4.1b。

3 个答案:

答案 0 :(得分:3)

我们通常只使用普通的xdv并使用rules.xml(或任何你想要的名称)文件来设置主题模板,将collective.xdv控制面板中的相应属性留空。在设置不同模板时,嵌套规则为您提供了一些灵活性:

<?xml version="1.0" encoding="UTF-8"?>
<rules xmlns="http://namespaces.plone.org/xdv"
   xmlns:css="http://namespaces.plone.org/xdv+css"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<theme css:if-content="body.section-front-page" href="frontpage.html" />
<theme css:if-path="/section/subsection/somefolder" href="somefolder.html" />
...
<rules css:if-content="#visual-portal-wrapper">
    <!-- The default theme -->
    <theme href="theme.html" />
    <rules css:if-content="body.section-somefolder">
        <!-- Secific rules for somefolder go here -->
        ...
    </rules>
</rules>

答案 1 :(得分:1)

当网址与特定正则表达式匹配时,您应使用备用主题设置来定义备用布局。

例如,我们有一个名为“Plone”的Plone站点,可在url localhost:8080 / Plone访问。要为主页提供不同的布局,我们可以在注册表中定义以下内容(或 Plone控制面板&gt; XDV设置部分中的TTW):

<record field="alternate_themes" interface="collective.xdv.interfaces.ITransformSettings" name="collective.xdv.interfaces.ITransformSettings.alternate_themes">
    <field type="plone.registry.field.List">
        <description>Define alternate themes and rules files depending on a given path. Should be of a form 'path theme rules' (or 'path rules' with xdv 0.4), where path may use a regular expression syntax, theme is a file path or URL to the theme template and rule is a file path to the rules file.</description>
        <required>False</required>
        <title>Alternate themes</title>
        <value_type type="plone.registry.field.TextLine">
            <title>Theme</title>
        </value_type>
    </field>
    <value>
        <element>^.*/Plone(/)?$ python://my.xdvtheme/templates/alternative/index.html python://my.xdvtheme/rules/alternative/index-rules.xml</element>
    </value>
</record>

这样,主页将使用替代布局,而所有其他页面将使用主题模板规则模板

中指定的主要布局

您可以根据网站的不同部分提供多个定义。

答案 2 :(得分:0)

我的个人Plone网站为不同的部分使用不同的主题和规则文件。

您是否在 / @@ xdv-settings 使用XDV控制面板?

主题模板规则文件字段中,我输入了默认(即最常用的)文件。

备用主题文本框中,您可以根据给定路径提供备用主题和规则文件。

格式为路径主题规则

以下是我网站配置中的一些示例:

  1. * / login_form | *。logged_out /home/zope/production/theme/theme.html /home/zope/production/theme/login.xml
  2. /媒体/博客$ /home/zope/production/theme/blog.html /home/zope/production/theme/blog.xml
  3. /媒体/软件 /home/zope/production/theme/software.html /home/zope/production/theme/media.xml
  4. 如您所见,您可以使用正则表达式语法来匹配路径。

    第一行用于设置登录和注销页面的样式。 第二个造型我博客的登陆页面(henche the $) 第三种是我的软件页面。

    像魅力一样。