Using Variables in Diazo

Chrissy Wainwright

Define Variables

Define variables in manifest.cfg using TALES expressions:

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

Reactivate Theme

The theme has to be reactivated to pick up new parameters.

Site Setup > Theming, click Deactivate, then reactivate.

Check variables

Site Setup > Theming > Advanced Settings

You should see your variables under 'Parameter expressions'.

The description also contains helpful information.

Use in rules.xml

Use variables prefixed with $:

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

In HTML in rules.xml, variables also needs to be wrapped in {}:

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

Expressions

You can also do simple expressions in the rules.xml:

<drop css:theme=".manageLink" if="$role != 'administrator'"/>
SpaceForward
Right, Down, Page DownNext slide
Left, Up, Page UpPrevious slide
POpen presenter console
HToggle this help