Hi,

I've never been a big fan of metal macros so I might be a bit biased here.

What I would do is instead of creating a slot for the header, populate it in your general.tpl file directly. Since you're already including a file in your pages to calculate the header contents, you could put there the tal instructions to fill up the header directly in the general template.

/imv

On 8/27/09 8:36 PM, GRolf wrote:


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
PHP.

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">
<body>
<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>
</body>
</html>

* 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 ...

</tal:block>
</tal:block>


* 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
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to