[Zope] Re: [Support] Re: Collector #2244: Zope, sequence-

Evan Simpson evan@digicool.com
Thu, 7 Jun 2001 11:31:42 -0400


From: "Chris Withers" <chrisw@nipltd.com>
> Say I want to build something like this:
>
> <<< Showing 4 to 10 of 400 >>>

Then you would probably find the Batch class from ZTUtils valuable.  It's
available from the same place as ZPT, which depends on it.  It doesn't have
all of the fancy features of dtml-in, but it is much simpler.  You pass the
sequence and batching parameters to the Batch constructor, and get an object
that you can iterate over normally (using dtml-in or Python for:).  Given
Batch instance "b":

<dtml-with b>
  <dtml-if previous><dtml-with previous>
    <a href="...?start=&dtml-start;">&lt;&lt;&lt;</a>
  </dtml-with></dtml-if>
  Showing &dtml-start; to &dtml-end; of <dtml-var expr="_.len(seq)">
  <dtml-if next><dtml-with next>
    <a href="...?start=&dtml-start;">&gt;&gt;&gt;</a>
  </dtml-with></dtml-if>
</dtml-with>

This code will work above, below, or inside of the <dtml-in b> loop.

Cheers,

Evan @ digicool