I have a legacy site that uses dtml mostly. I'm having brainlock here. Why does this not work? <dtml-if sequence-start> Show records. <dtml-else> No records returned. </dtml-if> Can anyone provide the proper syntax? Harlow Pinson Indepth Learning Email: hpinson@indepthl.com Web: http://www.indepthl.com Voice: 505-994-2135 FAX: 208-475-7678
I believe sequence-start (managed by the wrapping <DTML-IN> is None if the sequence is empty. So the fragment says-- show the records only if there are any On Fri, 27 Aug 2004 hpinson@indepthl.com wrote:
I have a legacy site that uses dtml mostly. I'm having brainlock here.
Why does this not work?
<dtml-if sequence-start> Show records. <dtml-else> No records returned. </dtml-if>
Can anyone provide the proper syntax?
Harlow Pinson Indepth Learning Email: hpinson@indepthl.com Web: http://www.indepthl.com Voice: 505-994-2135 FAX: 208-475-7678
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
----- Original Message ----- From: <hpinson@indepthl.com>
I have a legacy site that uses dtml mostly. I'm having brainlock here.
Why does this not work?
<dtml-if sequence-start> Show records. <dtml-else> No records returned. </dtml-if>
Can anyone provide the proper syntax?
What are you trying to accomplish? Typically the format is: <dtml-in ....> <dtml-if sequence-start> ...do something on the first loop iteration </dtml-if> ...do something for each iteration <dtml-if sequence-end> ...do something on the last loop iteration </dtml-if> <dtml-else> ...do something if the dtml-in loop did not execute at least once </dtml-in> HTH Jonathan
Yes, thanks-- that's exactly what I'm trying to do-- it's the example is the Zope book too I think. I do have the dtml in clause as you suggest (i think), but saving what the book and you suggest results in a syntax error: Here's the code that won't save: <table> <dtml-in SQL_getNames> <dtml-if sequence-start> <tr align="left" valign="top"> </dtml-if> <td height="28" bgcolor="white"> <dtml-var last_name>, <dtml-var first_name> <dtml-var middle_name null=""> </td> <dtml-if sequence-end> </tr> </dtml-if> <dtml-else> <p>No records are returned.</p></dtml-if> </tr> </dtml-in> </table> It seems maybe a closing </dtml-if> should be needed, but none of the examples I've found have that, and adding one does not help the dtml compile. Harlow Pinson Indepth Learning Email: hpinson@indepthl.com Web: http://www.indepthl.com Voice: 505-994-2135 FAX: 208-475-7678
Coming late on this thread, hope I'm not OT, or ignorant of the OP's problem ... hpinson@indepthl.com wrote:
<table> <dtml-in SQL_getNames> <dtml-if sequence-start> <tr align="left" valign="top"> </dtml-if> <td height="28" bgcolor="white"> <dtml-var last_name>, <dtml-var first_name> <dtml-var middle_name null=""> </td> <dtml-if sequence-end> </tr> </dtml-if> <dtml-else> <p>No records are returned.</p></dtml-if> </tr> </dtml-in> </table>
The dtml-else clause you are using here should be part of the dtml-in. You want: <table> <dtml-in SQL_getNames> <dtml-if sequence-start> <tr align="left" valign="top"> </dtml-if> <td height="28" bgcolor="white"> <dtml-var last_name>, <dtml-var first_name> <dtml-var middle_name null=""> </td> <dtml-if sequence-end> </tr> </dtml-if> <dtml-else> <tr align="left" valign="top"> <td><p>No records are returned.</p></td> </tr> </dtml-in> </table> ...or just: <table> <tr align="left" valign="top"> <dtml-in SQL_getNames> <td height="28" bgcolor="white"> <dtml-var last_name>, <dtml-var first_name> <dtml-var middle_name null=""> </td> <dtml-else> <td><p>No records are returned.</p></td> </dtml-in> </tr> </table> HTH, JZ
participants (4)
-
Dennis Allison -
hpinson@indepthl.com -
John Ziniti -
Jonathan Hobbs