Collective.xdv 和多个主题文件

发布于 2024-10-31 18:24:46 字数 295 浏览 1 评论 0原文

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

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

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

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

克隆人 4.1b。

I am having different theme HTML files for different site sections. There are some major layout differences depending if the page is the front page, or a certain subsection.

As far as I see the default behavior is just to have one HTML file:

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

What would be the best strategy to use multiple theme files, slight rule variations and collective.xdv?

Plone 4.1b.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

离笑几人歌 2024-11-07 18:24:46

我们通常只使用普通的 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>

We usually just utilize plain xdv and use the rules.xml (or whatever you want to call it) file to setup the theme templates leaving the corresponding properties in the collective.xdv controlpanel empty. Nesting rules gives you quite some fexibility when asigning different templates:

<?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>
枕梦 2024-11-07 18:24:46

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

例如,我们有一个名为“Plone”的 Plone 站点,可通过 url localhost:8080/Plone 访问。要为主页提供不同的布局,我们可以在注册表中定义以下内容(或在 Plone 控制面板 > 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>

这样,主页将使用替代方案布局,而所有其他页面将使用主题模板规则模板中指定的主布局。

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

You should use the Alternate Themes settings to define alternative layouts when the url matches a specific regular expression.

For example, we have a Plone site named "Plone" and accessible at url localhost:8080/Plone. To provide a different layout for the Home page, we can define the following in the registry (or TTW in the Plone Control Panel > XDV Settings section):

<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>

This way, the home page will use the alternative layout, while all the other pages will use the main layout specified in Theme template and Rules template

You can provide multiple definitions according to the different sections of your site.

若无相欠,怎会相见 2024-11-07 18:24:46

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

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

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

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

格式为路径主题规则

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

  1. .*/login_form|.*logged_out
    /home/zope/生产/主题/theme.html
    /home/zope/product/theme/login.xml
  2. /media/blog$
    /home/zope/生产/主题/blog.html
    /home/zope/product/theme/blog.xml
  3. /media/software
    /home/zope/生产/主题/software.html
    /home/zope/product/theme/media.xml

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

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

就像魅力一样。

My personal Plone site uses different theme and rules files for different parts.

Are you using the XDV control panel at /@@xdv-settings?

In the Theme template and Rules File fields I put my default (i.e most used) files.

In the Alternate Themes textbox you can then provide alternate theme and rules files depending on a given path.

The format is path theme rules.

Here are some examples from my website's config:

  1. .*/login_form|.*logged_out
    /home/zope/production/theme/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

As you can see, you can use regular expression syntax to match the paths.

The first line is for styling the login and logout pages.
The second for styling only my blog's landing page (henche the $)
the third styles my software page.

Works like a charm.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文