Collect.xdv and several theme files

I have different HTML theme files for different sections of the site. There are some basic markup differences, depending on whether the page is the main page or a specific unit.

As far as I can see, the default behavior is just one HTML file:

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

What would be the best strategy for using multiple theme files, small rule variations, and a collective .xdv?

Plone 4.1b.

+4
source share
3 answers

Usually we just use a simple xdv and use the rules.xml file (or whatever you want to name) to customize the theme templates, leaving the corresponding properties in the control panel collective .xdv empty. Nesting rules give you quite some opportunity when assigning 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> 
+3
source

You should use the Alternate Theme settings to define alternate layouts when the URL matches a specific regular expression.

For example, we have a Plone site called "Plone" and is available at localhost url: 8080 / Plone. To provide a different layout for the Homepage, 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> 

Thus, the home page will use an alternative layout, and all other pages will use the main layout specified in the Subject and Rules template

You can provide several definitions according to the various sections of your site.

+1
source

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

Do you use the XDV control panel in / @@ xdv-settings ?

In the Subject and Rules File fields , I put the default files (the most used).

In the Alternate Themes text box, you can provide alternative topic and rule files depending on the path specified.

The format is the rules of the theme of the path.

Here are some examples from my website:

  • .
  • * / login_form |. * Logged_out /home/zope/production/theme/theme.html /home/zope/production/theme/login.xml
  • / Media / blog $ /home/zope/production/theme/blog.html /home/zope/production/theme/blog.xml
  • / 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 paths.

The first line is for styling login and logout pages. The second is to stylize just my blog landing page (henche the $) is the third style of my software page.

It works like a charm.

0
source

Source: https://habr.com/ru/post/1347699/


All Articles