collective.xdv - define an alternative theme break

2019-08-09 04:29发布

I'm using plone 4.0.1 + collective.xdv 1.0rc11 and I need to use different themes.

I'm trying to do as described in a recent question/answer but when I insert a new theme with a condition I get no transform at all for the default theme. Here are some examples of what I tried:

<rules css:if-content="body.section-mysection">
    <theme  href="mysection.html" />
</rules>

this ends in:

Traceback (innermost last):
  Module ZPublisher.Publish, line 132, in publish
  Module zope.event, line 23, in notify
  Module zope.component.event, line 26, in dispatch
  Module zope.component._api, line 138, in subscribers
  Module zope.component.registry, line 323, in subscribers
  Module zope.interface.adapter, line 575, in subscribers
  Module plone.transformchain.zpublisher, line 93, in applyTransformOnSuccess
TypeError

While these:

<theme  href="mysection.html" if-path="/mysection/"/>

<theme  href="mysection.html" css:if-content="body.section-mysection"/>

both work for the given section BUT for the rest of the portal there is no transform at all.

I tried to specify also the default theme in the rules.xml (even if it's already registered into @@xdv-settings) with <theme href="index.html" /> but got no luck.

What am I missing here?

Thanks in advance, SimO

标签: plone xdv
2条回答
一纸荒年 Trace。
2楼-- · 2019-08-09 04:57

I am not sure if I understand your setup and your specific problem to the full extend, so I just post a working example. Note: we don't use a default theme value in the xdv control panel, since it will be obsolete with plone.app.theming anyway. It also seemed to interfere with setting up theme tempaltes in the rules.xml directly which might be relevant for your specific problem/usecase.

<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-content="body.section-contact" href="contact.html"/>

<!-- Only style actual Plone page and exclude things like /manage -->
<rules css:if-content="#visual-portal-wrapper">

    <!-- default theme templates -->
    <theme href="theme.html" />
    <!-- Add your default transform rules here -->
    <rules css:if-content="body.section-contact">
        <!-- Theme template is already setup on top of this file -->
        <!-- Add section specific rules here -->
        <drop css:theme="#sidebar" />
    </rules>
</rules>
</rules>

These rules are as close as possible to the setup required by diazo/plone.app.theming and should just need minor adjustments (namespace correction and a search/replace for append/after for example) - I just migrated the site this example has been lifted from to Plone4.1/diazo without any major drawbacks.

查看更多
做个烂人
3楼-- · 2019-08-09 05:00

First, I would consider moving on to plone.app.theming. The upgrade/change is fairly trivial as I understand it (http://pypi.python.org/pypi/plone.app.theming#migrating-from-collective-xdv) and p.a.theming provides all the latest and greatest features that were developed under collective.xdv.

Second, I would reference this document:

It sounds like you just need to configure the default theme first, and then add a condition(s) to change the appropriate section when the condition matches. The additional matched theme should not affect the "default" (first matched) theme.

查看更多
登录 后发表回答