I'm building a website and I'm wondering about the best approach ...

The goal is the following: there is a general design of every page
(header, main, footer). The content of the header changes based on the
visitors adminlevel (nearly every visitor has something else in the
header) - the exact content of this header is retrieved and parsed in

The other parts of the page (eg 'main'), depend on the PHP page and
can be handled by using a different file in setTemplate().

What I currently do:

* I have a 'general.tpl' file, which contains
<html tal:define-macro="generalstructure">
<div id="header"><tal:block tal:define-slot="header"/></div>
<div id="main"><tal:block tal:define-slot="main"/></div>
<div id="footer"><tal:block tal:define-slot="footer/></div>

* every PHP file (index.php, register.php etc) calls it's own script
file (index.tpl, register.tpl etc) via $phptal->setTemplate(). Each
file contains something like

<tal:block metal:use-macro="general.tpl/generalstructure">
<tal:block metal:fill-slot="main">

  I'm index.php ...


* every page (index.php etc) also contains included code to retrieve
the header content (retrieve_header($user_id));

How can I now best ensure that this header content is nicely parsed
into the header-slot, without having to put metal:fill-slot code in
each and every page template ?

Could somebody please give me an idea of PHPTal is supposed to handle
this kind of situations? If you have any other suggestions how to
improve this setup, be my guest ...

PHPTAL mailing list

Reply via email to