[Zope] Help with dtml-let & dtml-if
Ben Leslie
benno@sesgroup.net
Thu, 30 Mar 2000 11:12:00 +1000
Hi Andrew!
On Wed, 29 Mar 2000, Andrew Diller wrote:
>
> Hello:
>
> I'm not getting dtml-let. I use it to create a variable that I can access, correct?
>
> Say I want to initialize a counter, and change it from 0 1 each iteration of a loop.
>
> This will print out rows of a table with alternating background colors:
>
>
> <dtml-let x=0>
> </dtml-let>
>
> <dtml-in "getElementsByTagName('book')" >
>
> <dtml-if x==0>
> <tr bgcolor="DDEEAC">
> <dtml-else>
> <tr>
> </dtml-if>
>
>
> write out some html
>
> </tr>
>
> <dtml-if x==0>
> <dtml-let x=1>
> </dtml-let>
> <dtml-else>
> <dtml-let x=0>
> </dtml-let>
> </dtml-if>
>
> </dtml-in>
> </table>
> </dtml-with>
>
<dtml-let> tags only set that variable within the <dtml-let>context</dtml-let>
tags.
The task you wish to do would much easily done using the variables set by
dtml-in. Eg <dtml-var sequence-index> will print out the 'count' if you like
for the list.
<dtml-if sequence-start> </dtml-if> (from memory?) will evaluate if it is
the first iteration of the loop.
<dtml-if sequence-even> and <dtml-if sequence-odd> will evaluate odd and
even iterations of the loop, which is what it apears you want todo.
Check out the zope quick reference document for documentation on
this
http://www.zope.org/Members/ZQR.
Cheers,
Benno