[Zope] alternating colors based on sequence-index of outer loop

hans hans@beehive.de
Mon, 25 Mar 2002 11:42:50 +0000


John Hunter wrote:

> I have a folder called Sections that is filled with Section instances.
> Each Section contains a variable number of students, and I want all
> the students in a given section to have the same row color in my
> table, with sections alternating colors.
>
> I have nested dtml-in loops over the sections and students in each
> section, and want the rows of my table to alternate in batches
> depending on whether the outer loop is even or odd.  Basically, I need
> to do a dtml-let in the outer loop that the inner loop will access,
> but am having trouble with the syntax.
>
> Here is some example dtml with pseudo code to set the default_color
>
>       <dtml-in expr="Sections.objectValues('Section')" mapping>
>           <dtml-if sequence-even>
>              default_color="gray"
>           <dtml-else>
>              default_color="white"
>           </dtml-if>
>          <dtml-in expr="_['sequence-item'].objectValues('Student')" mapping>
>           <tr default_color>
>                 ..Fill in the row..
>            </tr>
>          </dtml-in>
>       </dtml-in>
>
> Thanks for any help,
> John Hunter

There is a prefix attribute to dtml-in, which allows you to name the
different sequence iterators.For details see
http://www.zope.org/Members/michel/ZB/AppendixA.dtml
cheers hans
-------------------------------------------------------------
Who's got only a hammer sees the world as a nail
hans augustin  (software developer)           hans@beehive.de
beehive elektronische medien GmbH       http://www.beehive.de
phone: +49 30 847-82 0                  fax: +49 30 847-82 299