Re: [Phplib-users] (no subject)
Brought to you by:
nhruby,
richardarcher
|
From: Lars H. <ph...@qu...> - 2001-10-07 10:28:28
|
Hi Roberto,
> On the template class, is there a way to have "master" templates for the
> whole site, that would be included in all other templates? It seems to me
> that by having to specify the root in every templated page, it wouldn't
> allow that functionality out of the box.
Maybe something like this works for you:
class MyTemplate {
var $Tpl = "";
function MyTemplate () {
$this->Tpl = new Template("/root/2/your/templates", "remove");
$this->setMainTemplate();
}
function setMainTemplate() {
$this->Tpl->set_file(array(
"mainPage" => "mainPage.tpl"
));
$this->Tpl->set_var(array(
"foo" => "bar"
));
}
function setContent($myContent = "") {
$this->Tpl->set_var("array(
"content" => "$myContent"
));
}
function showMainTemplate() {
$this->Tpl->pparse("mainPage");
}
}
$myTpl = new MyTemplate();
$myTpl->setContent("Hello, this is my content");
$myTpl->showMainTemplate();
You can extend your class MyTemplate with other templates or other vars.
The other way is to create a function, maybe parseHeader() or
something, which prints your header (powered by a template file)
and then call other templates and then you call parseFooter() or something.
HTH,
Lars
--
quiXS! | http://www.quixs.com
|