[Phplib-users] Re: Phplib-users digest, Vol 1 #238 - 4 msgs
Brought to you by:
nhruby,
richardarcher
From: Gerard H. <hi...@ma...> - 2002-07-10 20:58:56
|
> > Message: 1 > Date: Wed, 10 Jul 2002 12:38:19 +0800 > From: q <qua...@sn...> > To: php...@so... > Subject: [Phplib-users] templates with templates > > > I have a file viewTemplate.php > that uses template1.templ. > > Can I tell template1.templ to use another template (say, template1-a.templ)? > > Is this possible with phplib? templates with templates? (cascading) > > Thank you very much > Yes you can. If you read through the code long enough, you will find that the template files are read into and stored within the template object. The following are some snippets from some code I wrote to do what you are looking for. # initialize the template object $template = new Template ($Config->TemplateDir, $Config->UnknownTags); $template->halt_on_error = 'report'; $template->set_file (array ('homepage' => 'homepage.html', 'listing' => 'listing.html', 'detail' => 'detail.html', 'register' => 'register.html', 'recoverpw' => 'recoverpassword.html', 'changepw' => 'changepassword.html', 'memberdata' => 'memberdata.html', 'editevent' => 'editevent.html', 'editsched' => 'editsched.html', 'edittable' => 'edittable.html', 'editdatelist' => 'editdatelist.html', 'editinfobox' => 'editinfobox.html', 'eventsingle' => 'eventsingle.html', 'header' => 'header.incl', 'info' => 'info.incl')); # preload some common times to put on a page $template->set_var ('SYSTEMINFOBOX', $infobox->render_html ('system')); $template->set_var (array ('TODAY' => date ('n/j'), 'TODAYDOW' => date ('l'), 'SELF' => $SELF)); $template->parse ('HEADER', 'header'); $template->parse ('INFO', 'info'); This will allow the orignal template file to contain {HEADER} and {INFO} as tags to include the header.incl and info.incl. Almost all the other template files have these tags within them. Hope this helps. -- Gerard Hickey hi...@ke... Kernel Rom Security Services http://www.kernelrom.com/ Finger hi...@ke... for PGP keys and info. |