Personal tools

Contact Us 24/7 > 1 866.SIX FEET
Sections

Skip to content. | Skip to navigation

Home > Blog > How to use XSLT in Diazo
12/01/16

EVERYONE.NET SCHEDULED MAINTENANCE 

Everyone.net will be performing maintenance on their databases Friday December 2nd, 2016 between 9:00PM PT to 3:00AM PT / 12:00AM ET to 06:00AM ET. During this time, all services including web mail, POP, IMAP, and SMTP relay may experience degraded performance and inbound mail delivery delays. We apologize for any inconvenience.

Blog

How to use XSLT in Diazo

written by Chrissy Wainwright on Thursday December 4, 2014
Comments | Filed under: , ,

XSLT in DiazoWhat is XSLT?

It stands for 'eXtensible Stylesheet Language Transformations'. It is how Diazo works behind the scenes - all rules you write are actually translated to XSLT.

Why is XSLT needed?

It may not be needed at all, depending on how complex the selectors need to be in your Diazo rules. If you need to do anything involving loops or if statements, you'll need some XSLT.

Examples

<replace css:theme-children=".mainNav">
 <xsl:for-each css:select="#portal-globalnav > li">
   <li class="divider"></li>
   <xsl:apply-templates css:select="li.plain, li.selected"/>
 </xsl:for-each>
 <li class="divider"></li>
</replace>

This grabs each list item from Plone, and inserts a list item as a divider between each one. Note that the css: prefix can also be added to the XSLT within Diazo rules to use CSS style selectors.

<xsl:for-each css:select="#portal-personaltools a">
 <li>
   <xsl:copy-of select="current()"/>
 </li>
</xsl:for-each>

This pulls all links from the user dropdown and puts them into a list, instead of having them in a definition list.

Warnings

  • XSLT has a steep learning curve. Make sure you have plenty of time and patience before tackling XSLT on your own.
  • XSLT errors aren't very helpful. I don't have any good advice to help with this, except to maybe leave any expensive, breakable things out of your reach.

More examples and resources

I hope this gives you a brief understanding of how to utilize XSLT in your Diazo theme. You can find more examples and resources at:

 

Like what you've read? You can see more trainings like this one at sixfeetup.com/plone-cms/plone-how-to. Also, be sure to sign up for our weekly Plone & Python How-To digests.

 
Add comment

You can add a comment by filling out the form below. Plain text formatting.

puzzle

Next Steps


Select a type of support:

Contact our sales team

First name:
Last name:
Email:
Phone Number:
Message:
Fight spam:
What is + ?
 
Call Us 1 866.SIX FEET
Sections