Thanks for filling out the form! A Six Feet Up representative will be in contact with you soon.

Have a technical question? Ask a Sixie!

<< All Blog Posts
How to use Variables in Diazo

How to use Variables in Diazo

Variables can be used in your Diazo rules.xml from TAL expressions set in your theme. These variables are defined in your theme's manifest.cfg like so:

[theme:parameters]
portal_url = portal_state/portal_url
ajax_load = python: 'ajax_load' in request.form
anon_user = portal_state/anonymous

These are some commonly used variables. Just like TAL, they use path expressions by default, but python: or string: can be specified.Diazo concept graphic

If the parameters were set directly in the manifest.cfg, you will need to reactivate the theme in the Theming control panel (deactivate, then activate). The parameters can also be set in the control panel's Advanced Settings tab. Available variables that can be used within the expressions are context, request, portal, portal_state, and context_state.

Use in rules.xml

Use variables prefixed with $. If used in HTML within a rule, the variable also needs to be wrapped in curly braces:

<drop css:content="#portal-breadcrumbs"
      if-path="$portal_url"/>

<replace css:theme="#sitesearch">
  <form action="{$portal_url}/@@search" method="post">
  ...
</replace>

Simple condition expressions can also be done in the rules using the variables:

<drop css:theme=".manageLink"
      if="$role != 'administrator'"/>

 

I hope this gives you a brief understanding of how to apply variables in your Diazo theme. You can learn more at Diazo.org and also find more training like this one at sixfeetup.com/plone-cms/plone-how-to.

Like what you've read? Be sure to sign up for our weekly Plone & Python How-To digests.