I have the following code for setting up colors: <dtml-if BGCOLOR> <STYLE type="text/css"> BODY { background: <dtml-var BGCOLOR> } </STYLE> </dtml-if> <dtml-if VLINK> <STYLE type="text/css"> A:visited { color=<dtml-var VLINK> } </STYLE> </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> Since this would eliminate having an extra STYLE tag. When expanded to include all the various optional tags that could be included this could save alot of space. However, I can not figure out how to use an "or" with dtml-if. I have not got that good of a handle on using python expressions with dtml, I assume this will be necessary. Of course, I could just take the <STYLE></STYLE> tags outside of any dtml-if, but this would leave an empty STYLE element in alot of pages which is aesthetically displeasing to me, although that is what I will do if I can't figure out a better way. Can anyone help me with this problem? ---------------------------------------------------------------------- Harry Henry Gebel ICQ# 43675297 West Dover Hundred, Delaware ----------------------------------------------------------------------
Harry, First the general answer: Every logic and expression evaluation follows the syntax guide of Python. If you have problems with writing expressions for any tag just check the Python Documentation. They do an awesome job in explaining the Syntax. Here the answer to you specific question: Python does not use | as a keyword but instead the keyword "or". Therefore, <dtml-if "BGCOLOR or VLINK"> should do the job. regards, stephan -- Stephan Richter iXL - Software Designer and Engineer CBU - Physics, Computer Science and Chemistry Student
<dtml-if "BGCOLOR or VLINK"> should work ----- Original Message ----- From: Harry Henry Gebel <hgebel@inet.net> To: <zope@zope.org> Sent: Sunday, November 14, 1999 7:51 PM Subject: [Zope] How do I use "or" (|) with <dtml-if>
I have the following code for setting up colors:
<dtml-if BGCOLOR> <STYLE type="text/css"> BODY { background: <dtml-var BGCOLOR> } </STYLE> </dtml-if> <dtml-if VLINK> <STYLE type="text/css"> A:visited { color=<dtml-var VLINK> } </STYLE> </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>
Since this would eliminate having an extra STYLE tag. When expanded to include all the various optional tags that could be included this could save alot of space. However, I can not figure out how to use an "or" with dtml-if. I have not got that good of a handle on using python expressions with dtml, I assume this will be necessary. Of course, I could just take the <STYLE></STYLE> tags outside of any dtml-if, but this would leave an empty STYLE element in alot of pages which is aesthetically displeasing to me, although that is what I will do if I can't figure out a better way. Can anyone help me with this problem?
---------------------------------------------------------------------- Harry Henry Gebel ICQ# 43675297 West Dover Hundred, Delaware ----------------------------------------------------------------------
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope No cross posts or HTML encoding! (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
----- 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
participants (4)
-
Harry Henry Gebel -
Jim Sanford -
Kevin Dangoor -
Stephan Richter