[ZPT] Question on using metal-slots for menus
Charlie Clark
charlie at begeistert.org
Fri Jul 4 19:04:51 EDT 2003
Dear list,
I've been working with Zope on and off for nearly a year and am quite comfortable with ZPT now. However,
my initial site was done in DTML (it was easier to get into and meet the deadline with at the time) and
I'm now in the process of migrating it all to ZPT. Much of the work has been done already so that I just
have DTML templates calling ZPT's.
I have just started working with METAL but have so far been unable to work out the best way of having
context-based menus. My website's content is essentially static with a lot of RDBMS calls (through ZPT)
so I think I should be okay with a single page_macro and slots. What I'm struggling with is sub-menus. I
have just been through the list archive but have not seen anything on this.
Currently I have something like this:
<html metal:define-macro="page">
<head></head>
<body>
<a href="/search">Search</a><br>
<a href="/register">Register</a><br>
<a href="/about">About</a><br>
<div metal:define-slot="content">Welcome to my website</div>
</body>
</html>
What is the best way of providing folder-specific sub-menues for /search, /register and /about?
I initially tried using extra-slots like
<span metal:define-slot="search_navi" tal:omit-tag=""></span>
But found I couldn't define a macro in a page which uses master_page/macros/page - it seems any macros
defined in ZPTs which use the page macro are not available. While I think I understand this: everything
is discarded that is not in a slot, I was confused that I couldn't do this in search/index_html
<div metal:fill-slot="search_navi">
<span metal:define-macro="navi">
Normal search<br>
Advances searcg<br>
</span>
</div>
and call this macro by acquisiton from sub-folders.
So I have currently gone for using <tal:content="structure here/search_navi | nothing"> in my master_page
and having a mini-ZPT in the appropriate folder. While this works, it isn't exactly elegant.
Am I missing a major point? What are suggested ways of doing this which would allow me to overwrite the
master_page page_macro?
Thanx for your suggestions
Charlie Clark
More information about the ZPT
mailing list