[Zope] invoking a page template multiple times to display multiple sets
of data
Dieter Maurer
dieter@handshake.de
Tue, 15 Apr 2003 22:08:31 +0200
Alec Munro wrote at 2003-4-14 17:04 -0300:
> I have an array containing two objects of the same type. I have a page
> template that creates an HTML representation of an object of that type,
> based on the knowledge that an object of that type will be in variable X
> . I want both objects to be displayed on the same page, in different
> places.
> I could accomplish this by wrapping the page template in a script,
> telling that script explicitly which object to use, and having the
> script set variable X to be equal to the object. But so far I have shied
> away from having a level of python between my page templates.
> I'm wondering if anyone has another solution to my problem, or can give
> me information on the advantages or disadvantages of doing it the way I
> described above.
You can call page templates and pass them parameters (thus, you
do not need to add a script in between):
<tal:div content="python: yourTemplate(yourVariable=Value1)" />
....
<tal:div content="python: yourTemplate(yourVariable=Value2)" />
You can access the variable via "options" in your template
<tal:div define="
yourVariable yourVariable | options/yourVariable;
"
>
....
</tal:div>
Dieter