On 27 Feb 2009, at 12:16, Moritz Baumann wrote:

is there any way to make PHPTAL process dynamically inserted content?

$phptal->setSource('<html>') lets you execute a template without a file.

I want to use a »skeleton template« for my website which could look as follows:


 <div id="header">
  <tal:block tal:repeat="app headerElements">
   <tal:block metal:use-macro="{$app}.html/headerElement"


 <div id="content">
  <tal:block metal:use-macro="{$requestedApp}.html/content" />


Depending on which page has been requested, content area, sidebar, header etc.
would be filled with the appropriate content. (e.g. if you request
example.com/blog a tag cloud will appear in the sidebar and the latest blog
entries will be shown in the content area)

It's not possible to refer to dynamically generated template from metal:use-macro, however you could solve this problem by using macros and slots:

<html metal:define-macro="skeleton">
  <tal:block metal:define-slot="header" />
  <tal:block metal:define-slot="content" />

another file:
$phptal->setSource('<tal:block metal:use-macro="skeleton.html/skeleton">
  <div metal:fill-slot="header">Hello</div>
  <div metal:fill-slot="content">world</div>

regards, Kornel

PHPTAL mailing list

Reply via email to