[Zope3-Users] Re: ZPT Reuse

Philipp von Weitershausen philipp at weitershausen.de
Fri Nov 19 13:28:47 EST 2004


Craig Ewington wrote:
> I have a content component that I want to render the same way in a 
> number of different pages.  Rather than replicating the zpt in each 
> page, I'd like to factor it into one place.  ViewPageTemplate(...) looks 
> promising, but I can't quite figure out how to bind a page template to a 
> view and context object then have it render inside another page.  Can 
> anyone recommend a code snippet for me to look at?

You write a page template defining a METAL macro (e.g. 'foomacro') with 
the markup you want to be repeated. You register this as a regular 
browser page for the component, e.g. under the name 'foomacropage'. Then 
in other views where you want have 'foomacro' from 'foomacropage' 
included, use:

<xxx metal:use-macro="context/@@foomacropage/foomacro">

...
</xxx>

Philipp



More information about the Zope3-users mailing list