[Zope] Newbie: Confusion at sequence-odd, sequence-even and sequence-start
Alfredo P. Ricafort
alpot@mylinuxsite.com
09 Nov 2002 13:06:15 +0800
Hi,
I have this code that display images in a 2-column table. The idea is
for <dtml-in> to loop inside a folder containing these images. When the
counter is odd, an opening <tr> will be inserted; and when a the counter
is even a closing </tr> is inserted as well.
---------------------
| Image 1 | Image 2 |
---------------------
| Image 3 | Image 4 |
---------------------
The code is like this:
<table width=100% border=1>
<dtml-in objectValues>
<dtml-if sequence-odd> # Check if the sequence no. is even
<tr> and create a row.
</dtml-if>
<td> # Create a column and
<dtml-var sequence-number> insert the image or text
</td>
<dtml-if sequence-even> # Close the table if even
</tr>
</dtml-if>
</dtml-in>
</table>
When I ran this code, I noticed that in the first iteration, when the
sequence-number is 1, the condition <dtml-if sequence-odd> is not
satisfied while the <dtml-if sequence-even> is! So the first few lines
of the generated HTML would appear like this. Notice that the 1 column
(<td></td>) is created first before the row.
<table width=100% border=1>
<td>
1
</td>
</tr> #
<tr>
:
:
So, could somebody explain to me what is going on here. Why can't Zope
recognize the first iteration as an odd number, when the value of the
sequence-number is 1. And why is the statement <dtml-if sequence-even>
is satisfied at this point?
Thanks.
AL