[Zope] Building a list in a dtml-in loop

Thomas B. Passin tpassin@mitretek.org
Tue, 19 Jun 2001 10:23:17 -0400


[Schmidt, Allen J]

> I have a page that uses a dtml-in to process the results from a ZSQL
method.
> The page lists out 30 items and the price of each item is a link to a
detail
> page. What I would like to do is while inside the loop, create then append
> to a list that stores each of the record IDs for each item. Then when
> someone clicks the link to go to the detail page it 'takes' the list
along.
> On the detail page would be info about the product and also include
forward
> and back buttons to the next item in the list just created.
>
> I guess the question is can I create a list that I can pass to the next
page
> to use to access subsequent records.
>

First you need a candidate HTML plan, then you can figure out how to build
it with Zope.  The most HTML-ish way is to use hidden fields in an HTML
form.  All the hidden fields can have the same name, then their values will
be stored in the REQUEST for the page as a list that you can iterate over or
whatever.

If your loop through the ZSQL results already occurs in a form, you can just
add the hidden field at each iteration.  Otherwise, you probably will have
to use a second  pass through the results to build the form with the hidden
fields.

If you have to create a separate form for the hidden list, you will have to
use javascript to submit the form when the user clicks the detail link.  You
can get that to happen inside an html href link like this:

<a href='javascript:dispatch(id)'>Click here for details page</a>

Here, "dispatch()" is a function you write, and "id" is a value (written by
Zope) that tells dispatch() which item to dispatch, or perhaps where to link
to (probably it will be a url).

Cheers,

Tom P