[ZPT] page layout by "including" objects
Ron Bickers
rbickers-dated-997886078.5c8194@logicetc.com
Wed, 8 Aug 2001 10:34:38 -0400
> -----Original Message-----
> From: zpt-admin@zope.org [mailto:zpt-admin@zope.org]On Behalf Of Magnus
> > <metal:div define-macro="quote">
> > <tal:div define="here
> > python:whrandom.choice(root.Quotes.objectValues())">
> > <metal:div
> > use-macro="root/Quotes/view/macros/viewquote">Random Quote
> > Table</metal:div>
> > </tal:div>
> > </metal:div>
> >
> > Q: Is it safe to redefine 'here' in the div block?
>
> Though I don't see the need for doing it, I guess it should be safe in the
> example above.
The idea was that I could create the 'view' template that uses 'here' and
call it from the Web, as in '/Quotes/quote1/view' such that 'here' would be
'quote1'. In addition to being able to call it via the Web, I could also
define 'here' as a specific quote (as shown above) and use the same 'view'
template to display it. Make sense?
> <div metal:define-macro="quote">
> <table>
> <tr>
> <td
> tal:content="python:whrandom.choice(root.Quotes.objectValues())">Q
> uote</td>
> </tr>
> </table>
> </div>
Exactly. This is a simple example. However, if I were to have a complex
'view' template for a single quote and wanted to reuse it in situations
other than this random choice one, it would make sense to break it down into
two macros, right? For example, I might want to loop through 4 random
quotes and 'view' each, or sort them all by date, etc.
_______________________
Ron Bickers
Logic Etc, Inc.