[Zope] Page Templates are great, but...
Evan Simpson
evan@4-am.com
Sun, 02 Jun 2002 14:11:20 -0500
KevinL wrote:
> There seems to be two ways to manage this stuff. Metal is great, but
> will push you into building "well-formed" modules - so instead of
> standard_header and standard_footer, you build a standard_page macro,
> which contains both, and feed your content into that. It's a bit wierd,
> but it works well.
Please realize that this use of METAL, while a fairly effective way to
implement uniform page layouts, is not its primary use! This often
seems to be lost on newcomers to ZPT, whose first exposure to METAL is
this rather advanced and complex case.
The simplest, most straightforward use of METAL is to pull reusable
snippets from a library page, or simply from a page that is "typical" of
part of your site.
Suppose, for example, that the index_html of your site has a copyright
notice at the bottom. You can mark this notice for reuse throughout
your site without doing the whole page macro dance, like so:
<div id="copyright" metal:define-macro="copyright">
This page ©2002 Foobly Enterprises LLC, all rights reserved.
</div>
Now you reuse it in other pages with:
<div metal:use-macro="here/index_html/macros/copyright"></div>
No slots or other complications needed. Any TAL in the macro is
executed as though it were part of the page that's using it, so you
don't need to worry about passing parameters, or losing context, or any
of the difficulties introduced by calling one template from another. An
addition advantage over <span tal:replace="structure here/zpt_snippet">
is that a single page can define any number of independent macros.
Cheers,
Evan @ 4-am