[Zope] How do I use "or" (|) with <dtml-if>
Kevin Dangoor
kid@kendermedia.com
Sun, 14 Nov 1999 22:38:45 -0500
----- Original Message -----
From: Harry Henry Gebel <hgebel@inet.net>
To: <zope@zope.org>
Sent: Sunday, November 14, 1999 8:51 PM
Subject: [Zope] How do I use "or" (|) with <dtml-if>
> I would like to have something like this:
>
> <dtml-if BGCOLOR | VLINK>
> <STYLE type="text/css">
> <dtml-if BGCOLOR>
> BODY { background: <dtml-var BGCOLOR> }
> </dtml-if>
> <dtml-if VLINK>
> A:visited { color=<dtml-var VLINK> }
> </dtml-if>
> </STYLE>
> </dtml-if>
When you use dtml-if without quotes, Zope looks to see if the variable
exists and if it evaluates to true. To do an 'or', you need to have Zope
evaluate a python expression, so you need to use quotes...
<dtml-if "BGCOLOR or VLINK">
Note that this does not check for the existence of BGCOLOR or VLINK. It just
checks to see if they evaluate to true. To check the existence as well, you
could do:
<dtml-if "(_.has_key('BGCOLOR') and BGCOLOR) or (_.has_key('VLINK') and
VLINK)">
Kevin