[ZPT] Filling slots in METAL macros...

Tony McDonald tony.mcdonald@ncl.ac.uk
Thu, 26 Jul 2001 08:54:30 +0100


On 25/7/01 8:58 pm, "Evan Simpson" <evan@digicool.com> wrote:

> Tony McDonald wrote:
> 
>> In my obox page template, I have this..
>> <div metal:define-macro="obox">
>> ...
>> <th><b metal:define-slot="var1">title for Obox</b></th>
>> ...
>> </div>
>> 
>> 
>> I have tried this;
>> <html  metal:use-macro="here/obox/macros/obox">
>> ...
>> <div metal:fill-slot="obox">
>> </div>
> 
> The slot names need to match, and you probably want the tag to remain a
> <b> tag:
> 
> <b metal:fill-slot="var1">Local Title</b>
> 
> Cheers,
> 
> Evan @ Zope
> 

Thanks Evan,
That worked, but (sorry) - it's a little unintuitive (at least to me).

I would have thought I could go
<div metal:fill-slot="obox"

Then some mechanics in the DIV tag to pass through values that are used to
fill in the other slots in the macro
>

/div>

One of the things I really like about the idea of macros is that I can have
complex table constructs looked after by the designers, whilst I can then
reuse whatever they produce over and over again, but changing content as
necessary (we used to use Obox a lot when we were using Roxen).

I guess I could do this
<div metal:fill-slot="obox">
<boxtitle metal:fill-slot="string: Hello World"/>
(etc)
</div>

And have the macro look something like this;
<div metal:define-macro="obox">
<table  border=0 cellpadding=0 cellspacing=0 width=600>
<tr><td colspan=2><font size=-3>&nbsp;</font></td>
<td rowspan=3 nowrap><boxtitle metal:define-slot="obox_title">title for
Obox</boxtitle></td>
 
....

Doing it this way seems more intuitive (at least to me).

The other thing is that I want to have a standard_look_and_feel macro used
for the page, but then call in the obox-type macros as well.

This didn't work;

<!-- Page Template Diagnostics
 Compilation failed
 TAL.TALDefs.METALError: define-macro and use-macro cannot be used together
or with define-slot or fill-slot, at line 7, column 1
-->
<html  
metal:use-macro="here/standard_look_and_feel/macros/master">
  <head>
    <title tal:content="template/title">The title</title>
  </head>
  <body>
<div metal:fill-slot="obox"
metal:use-macro="here/obox_template/macros/obox">
<b metal:fill-slot="obox_title"><span
tal:content="template/title"></span></b>
</div>
  </body>
</html>

Am I doing something daft here? The idea of having different skins on our
material is something we have to look at and PT does it so elegantly.


The last thing (honest) is that I noticed from a new Zope site mockup that
there was a link saying 'PT source'. I guess if that site were near to
completion I and many others could benefit massively from it (I learnt
stacks from the 'show source' button on the Zope site.

Sorry this is a bit long - I have spent a long time trying to grok PT and I
keep feeling I must be missing something brutally obvious. Any pointers
would be great.

Cheers,
Tone.
-- 
Dr Tony McDonald,  Assistant Director, FMCC, http://www.fmcc.org.uk/
The Medical School, Newcastle University Tel: +44 191 243 6140
A Zope list for UK HE/FE  http://www.fmcc.org.uk/mailman/listinfo/zope