首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >collective.xdv和多个主题文件

collective.xdv和多个主题文件
EN

Stack Overflow用户
提问于 2011-04-12 18:42:15
回答 3查看 452关注 0票数 4

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

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

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

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

Plone 4.1b。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2011-04-13 02:15:21

我们通常只使用普通的xdv并使用rules.xml (或者你想叫它的任何东西)文件来设置主题模板,在collective.xdv控制面板中保留相应的属性为空。嵌套规则为您在设计不同模板时提供了相当大的灵活性:

代码语言:javascript
复制
<?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>
票数 3
EN

Stack Overflow用户

发布于 2011-04-13 16:46:15

当url与特定的正则表达式匹配时,应使用Alternate Themes设置来定义替代布局。

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

代码语言:javascript
复制
<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>

这样,主页将使用备用布局,而所有其他页面将使用在主题模板Rules模板中指定的主布局

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

票数 1
EN

Stack Overflow用户

发布于 2011-04-13 16:11:15

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

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

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

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

格式为路径主题规则。

下面是我的网站配置中的一些例子:

  1. .*/login_form|.*logged_out /home/zope/production/Theme.html /home/zope/production/theme/login.xml
  2. /media/blog$ /home/zope/production/theme/blog.html /home/zope/production/theme/blog.xml
  3. /media/software /home/zope/production/theme/software.html /home/zope/production/theme/media.xml

如您所见,您可以使用正则表达式语法来匹配路径。

第一行用于设置登录和注销页面的样式。第二个用于样式化我的博客的登陆页面(henche The $),第三个用于样式化我的软件页面。

就像一种护身符。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5633951

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档