[Zope] ZSQL and DTML question
Joel Burton
joel@joelburton.com
Thu, 7 Mar 2002 09:41:33 -0500 (EST)
On 7 Mar 2002, Mitch Pirtle wrote:
> Thanks for the quick response. This doesn't solve my problem, though.
> Where do you conditionally put the HTML for the table (that does not
> belong in the loop)?
>
> So (for example) I really want to:
>
> if(query returned results)
> print <table>, header row once, not in loop
> *** NOW loop on the query results for each <TR> ***
> print </table> once, not in loop
> else
> print "<p>Sucks to be you, homey.</p>\n" // NO TABLE
> endif
>
> I am not into doing this as a python script, and then passing every
> query to it for HTML formatting - each row may have arbitrary links
> added based on either the query or calling method, so it cannot be
> reused as a generic object.
>
> Or am I approaching it the wrong way?
One way:
<dtml-let results="theQuery()">
<dtml-if results>
<table>...blah blah blah
<dtml-in results>
<tr>...</tr>
</dtml-in>
</table>
<dtml-else>
Noting. Does that just suck?
</dtml-if>
</dtml-let>
Another way:
<dtml-in "theQuery()">
<dtml-if sequence-start>
<table>
</dtml-if>
<tr>...</tr>
<dtml-if sequence-end>
</table>
</dtml-if>
<dtml-else>
Nothing. What a sad thing.
</dtml-in>
--
Joel BURTON | joel@joelburton.com | joelburton.com | aim: wjoelburton
Independent Knowledge Management Consultant