Attention

This document was written for an old version of Plone, Plone 3, and was last updated 930 days ago.

To learn how to upgrade to the current version of Plone, read the upgrade manual.

XDV rules

by Denys Mishunov last modified Nov 04, 2009 08:05 AM
What rules XDV has and how they work.

XDV has a basic set of rules that should solve most of the theming needs. Rules are given in order of their application.

  • before - copies specified element(s) from the Plone site right before an element in the theme;
  • drop - drops the whole element(s) either in Plone or in the theme. Has 2 optional parameters:
    • content=“” - specifies element(s) in the Plone site to drop. If this parameter is specified no other parameters in the same rule are taken into account;
    • theme=“” - specifies element(s) in the theme to drop.
    • if-content=“” - condition that only works together with the theme="" parameter. If if-content=“” returns True, the node specified in theme="" is dropped from the output. if-content tests against element(s) in the Plone site.
  • replace - replaces the whole element(s) in the theme with the element(s) from the Plone site;
  • prepend - copies specified element(s) from the Plone site as the very first child of an element in the theme;
  • copy - copies specified element(s) from the Plone site into an element in the theme;
  • append - the same as prepend, but the Plone element(s) is copied as the very last child of an element in the theme;
  • after - copies specified element(s) from the Plone site right after an element in the theme.

Take a look at pages 27-33 of the From design to Plone site. XDV-driven Plone theming. presentation for a visual explanation of each of the rules.

Rules except copy/replace/drop can be applied more than once to each element in the theme. This means that you can’t apply 2 replace or 2 copy rules to the same element in the theme. Though it’s not a big loss - if you need to do this there must be something wrong with your theme.

In general all rules support the if-content condition, not only <drop />. But using it on <drop /> only should solve most of the use cases.

If more than one distinct rule is applied to the same theme element, the order above will be used and the rule that has the higher priority will be enforced. This means that if you have copy and replace rules on the same theme element, replace will be enforced no matter what the order of these rules is in your rules.xml. All rules use XPath version 1.0 for specifying elements.


Contribute

Something wrong or out of date? Anybody can edit or create a new article in the knowledge base. Simply create an account on this site, log in, and click the Edit button to contribute.