|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
tdm Smarty Rookie
Joined: 01 May 2003 Posts: 18
|
Posted: Mon Aug 18, 2003 5:24 pm Post subject: Setting {config_load....} per template? |
|
|
Quote: | note: I'm playing with the config files for the first time
|
I got the following files which are included at almost every page:
- pageheader.tpl
- header.tpl
- footer.tpl
- pagefooter.tpl
For example my news.php page, it needs the:
- pageheader.tpl
- header.tpl
- footer.tpl
- pagefooter.tpl
Like almost all pages, then it also need the template for the news page:
- news.tpl
The header and footer templates, and almost ofcourse, the news template, need it's own config section loaded.
So I tried putting the config_load part in the header and the footer templates, but I don't get an output.
Only when I put the config_load's into the news template I get the output from the config files for the header and the footer.
Isn't it possible to just put the config_load's ONLY in the files where A specific config section is needed (like in my header and footer templates)??
Because I want to use as less as possible duplicated code for the easiest maintainance of the website later on.
Any ideas? |
|
Back to top |
|
CirTap Smarty Pro
Joined: 04 Jun 2003 Posts: 106
|
Posted: Mon Aug 18, 2003 5:58 pm Post subject: |
|
|
Hi,
if news.tpl is the main template including the others, then you'll have all the config vars loaded there in the subtemplates as well.
If you read a config file in a sub template, the values are "local" to this file, e.g. in pageheader.tpl, {config_load file="foo.conf" section="head"} will
a.) return only the variables from [head] and
b.) they'll be available to pageheader.tpl only.
If you need variables from [head] in pagefooter.tpl as well, you'd either have the main template to load this section, move the stuff from [head] into the global part of the config file, or add a second {config_load file="foo.conf" section="head"} to pagefooter.tpl.
If the [head] section contains "shared" information like a copyright, company/author name, i.e. both used for <meta> tags and a copyright notice at the end of each page, just move them to the "global" part at the beginning of your config file.
You can then do a simple {config_load file="foo.conf"} in news.tpl or the other main templates and the subtemplates can access the variables.
Have fun,
CirTap |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|