[Zope] A conditional dtml-in tag?
RI Dunfey
s0231134 at sms.ed.ac.uk
Mon Feb 16 11:32:21 EST 2004
Hi-
I have a dtml page which displays the results of a sql query:
<dtml-in expr="my_query(category1=category1, category2=category2)">
<TR><TD>
<dtml-var NAME>
</TR></TD>
</dtml-in>
The values that are passed to the query are obtained from the request object.
If the value for category2=None then I want to leave category2 out of the sql
query as below:
<dtml-in expr="my_query(category1=category1)">
<TR><TD>
<dtml-var NAME>
</TR></TD>
</dtml-in>
The sql query has been designed to handle this using the optional tag.
However, it falls over if I break the in tags up with an if tag, e.g.:
<dtml-if "category2=None">
<dtml-in expr="my_query(category1=category1)">
<dtml-else>
<dtml-in expr="my_query(category1=category1, category2=category2)">
</dtml-if>
<TR><TD>
<dtml-var NAME>
</TR></TD>
</dtml-in>
I have also tried passing a string to the in tag, e.g.:
<dtml-if "category2=None">
<dtml-var dummystr="my_query(category1=category1)">
<dtml-else>
<dtml-var dummystr="my_query(category1=category1, category2=category2)">
</dtml-if>
<dtml-in expr=<dtml-var dummystr>>
<TR><TD>
<dtml-var NAME>
</TR></TD>
</dtml-in>
but the in tag cannot except a string? I have also tried handling this in
python, as it is logic, however this too has been unsuccessful and would quite
allow me to format the results as desired. I just want to control how the sql
query is executed? Depending on the value of variables in the request object.
Any help, much appreciated,
Rob
More information about the Zope
mailing list