[ZPT] Question on using metal-slots for menus

Fernando Martins fmartins at hetnet.nl
Sun Jul 6 17:42:56 EDT 2003


From: Charlie Clark
> > FWIW, it seems you want a sub-templating system, i.e., two levels of
> > macros:
> >
> > /master_page
> > /search/sub_master_page
> > /search/index_html
> > /register/sub_master_page
> > /register/index_html
>
> Actually I want to avoid that.

Yeah, I'm not sure I understand exactly what is your problem.

>
...
> An alternative would
> to have a macro inside a navigation template and call that in the slots.
>
> /master_page
> <html metal:define-macro="page">
> <head></head>
> <body>
> <a href="/search">Search</a><br>
> <div metal:fill-slot="search_navi">
> <span metal:use-macro="here/search_navi/macros/search_navi"></span></div>
> <a href="/register">Register</a><br>
> <a href="/about">About</a><br>
>
> <div metal:define-slot="content">Welcome to my website</div>
>
> </body>
> </html>
>
> /search_navi
> <html>
> <head></head>
> <body>
> <span metal:define-macro="search_navi"></span>
> </body>
> </html>
>
> I think this should work but it is still far from perfect.

Hmm, you can't do a fill-slot before doing a use-macro (see master_page).
But I also can't understand what you are trying with this example.

Another possibility to have sub-menus would be to put all the sub-menus in
the master_page. The HTML elements for each sub-menu would be inside a
define-slot. Each page using this master_page would do an empty fill-macro
for the non-relevant sub-menus, so that only the relevant sub-menu would
survive. Not elegant but simple.

So far, to build the sub-menus you have:

1) Put them in snippets of HTML stored in each in the respective sub-folder;
each sub-folder page would have to include it explicitly with a
tal:replace="structure here.snippet". This was the approach I thought you
were following.

2) To avoid repeating this inclusion in each page, you factor it into a
sub-template in each sub-folder. All the folder pages use this template, not
the master_page. That's what I suggested initially.

3) You put the sub-menus in the master_page and eliminate those you don't
need in each page.

Other options?

>
> By the way I've never come across tal / metal :block before. Is
> this just a
> way of reducing the number times of tal/metal has to be typed?
>

Not really (at least I don't think that's a good practice). They are used
when you can't use a div. See this recent thread:

http://mail.zope.org/pipermail/zope/2003-June/137345.html


Regards,
Fernando




More information about the ZPT mailing list