zopedtml

Zope/Plone If Statement Evaluation


I have two very distinct regions of my page that I would like to swap between based on a the setting of a dtml-var.

The variable is loaded when the page is built and is called GENDER_DESC. I can display the contents with <dtml-var GENDER_DESC>, the GENDER_DESC object will either be null, Female or Male.

What I would like to do is have a dtml-if statement that switches the content based on the state of that GENDER_DESC variable.

I have tried something like this:

<dtml-if expr="GENDER_DESC = 'Female'">
    <img src="student_photo?key=&dtml-SID;" style="height:140px; width:190px; border:5px solid black "/>
</dtml-if>

And a few other variations on that concept, but I cannot get the syntax correct.

How would I go about doing this?


Solution

  • DTML expressions need to be valid Python. In Python, "=" is the assignment operator. You probably want to test equality; the operator for that is "==".