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:

<html>
<head>
 [...]
</head>
<body>

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

 [...]

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

</body>
</html>

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:

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

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>
</tal:block>');

--
regards, Kornel


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

Reply via email to