[Zope] Help with iterating thru a list of objects

Michael Gutmann gutmann@uni-duesseldorf.de
Fri, 29 Jun 2001 14:01:41 +0200


Dario Lopez-K=E4sten wrote:

 > Hello!
 >
 > I need to display the results of an sql query and I need to compare th=
e
 > value of field A in the current item with the value of field A in the
 > previous item, in order to display things correctly.
<...>

Well, I don't know if it fits in your case, but did you think of dtml-ins
marvellous grouping abilities? You just have to sort on an attribute
and afterwards you can use first-<attribute> and last-<attribute> to
determine, if the values of the attribute have changed:

<dtml-in sql-search sort=3Doffice>

<dtml-if first-office>
<h1><dtml-var office></h1>
<table>
</dtml-if>

<tr><th>Name</th><td>&dtml-name;</td></tr>

<dtml-if last-office>
</table>
</dtml-if>

</dtml-in>


<dtml-unless there's no typo in it and you have defined all the variables=
>it may work</dtml-unless> ;-)
happy zoping,
Michael

--=20
Michael Gutmann M.A.
gutmann@uni-duesseldorf.de
Multimediazentrum Heinrich-Heine-Universitaet Duesseldorf