Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Recursive Template request

Quote Reply
Recursive Template request
I'ld like the ability to set template variables, that contain other template variables. i.e. I'm using the Yahoo templates, and want to add something to the top of every page. Right now, I have to edit 10+ files. Instead I'ld like a variable <%yahoo_top_html%>, that contained other <%_%> variables. As it stands now, the .html file is parsed, and it's variables substituted, without checking to see if the variables reference other variables.
Quote Reply
Re: Recursive Template request In reply to
At the top of site_html_templates.pl, you can define variables for whatever you will need globally. Then, just include a reference to them in the %globals variable and they will be available in the templates.

For example, if you wanted a header to use on various pages, you could define:

Quote:
$my_header = qq|your HTML code here|;

The HTML code would include the other variables but not as <%..%> type variables since they are only available in templates. All variables used in the HTML code would have to be defined at the top of site_html_templates.pl (or in links.cfg).

Then include the following in the %globals variable list:

Quote:
my_header => $my_header,

Now, on any template where you want the header to appear, you just use <%my_header%>.

I hope this helps.