On Sun, Feb 24, 2002 at 06:35:22PM -0000, Phil Taylor wrote:
> I want to define a master template which governs the overall appearance of my pages, 
>for example this could be a page with a common header and a "breaker" column down the 
>left and right side of the page. This will allow me to change the appearance of my 
>whole site by simply editing one template.
> 
> I  then want to define the middle part of the page with other templates and then use 
>HTML::Template to pull it all together.
> 
> I can't work out a clean way of doing this other than creating two HTML::Template 
>objects and pushing the $subTemplate->output() into a 
> $masterTemplate->param(....). Is there a better way of achieving this?
> 
> I came round to thinking that the ideal would be to have the param method accept a 
>template as a parameter value.
> 
> Phil


I essentially solved the problem by creating a new module (lets call it
SuperTemplate) which instantiates HTML::Template.

SuperTemplate accepts parameters like (header => 'header1',layout=>'layout2', footer 
=> 'none').
The parameters correspond to actual template files on disk. There are
also reasonable defaults so most of the time, those parameters are not even
specified.  SuperTemplate then builds a string which translates these into
'<tmpl_include>' commands and that string gets passes to HTML::Template.

Here's the real answer to your question: One of the files, usually the
layout file, has a  '<TMPL_CONTENT>' tag in it, which is replaced, using a
filter (look for that in the HTML::Template docs) with the real content,
which is either a <tmpl_include> referencing the subtemplate file, or a
piece of html.

This works best if you have named, categorized, and grouped most components of
your pages such that each component can be abstracted behind template files
which are only referenced by name (not filename, but abstract names) by the
scripts. Then SuperTemplate can figure out how to build each page from the
requested sections and/or defaults.

-Gyepi Sam

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to