On 14.06.2009, at 21:53, Shaun O'Connell wrote:

Problems with variables
Now I want to start defining variables per page, that the master template will use. E.g. a <title> suffix, or attaching a class to the <body> element. So, in index.php I added the body_class and title_suffix variables:
[index.php]
<?php
require_once 'lib/PHPTAL.php';
$template = new PHPTAL('index.html');

$body_class = 'home';
$title_suffix = ' - Home';


So, 3 questions:
• How and where should I define global variables that'll be used by the master template?

Variables that PHPTAL "sees" should be defined this way:

$template->body_class = 'home';
$template->title_suffix = ' - Home';

• How do I get variables defined by the calling template to be used by the master template?

Macros "inherit" all variables from template that calls them - you don't need to do anything special here.

        • Or is there a better way to approach all this?


That's right way to do it. You just need to fix definition of variables.

--
regards, Kornel




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

Reply via email to