Re: [SMARTY] Set config file from php?
| From: | Monte Ohrt | Date: | Thu, 09 May 2002 15:18:01 +0000 |
| Subject: | Re: [SMARTY] Set config file from php? | ||
| References: | 1 2 3 4 5 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-4125@lists.php.net to get a copy of this message | ||
That is probably why you should put your config_load line in a header template, which is included by all your templates that render a page.
Your template writers (as you call them) should be the ones controlling where config files get loaded, what sections are loaded, and where the configs are used in the template. They cannot do this when you load your configs in the application.
We too run quite a complex system with multiple clients, all completely themable with configs at a global and local scope and all the applications running within the same framework so they all follow the same look and feel. This kind of environment is what Smarty was designed around.
But anyways, you can accomplish what you want by using the Config_File.class.php directly. Load the config file and assign it to your template.
$conf = new Config_File('./configs');
// load globals
$smarty->assign($conf->get('mytheme.conf'));
// load one section
$smarty->assign($conf->get('mytheme.conf','mysection'));
// load one var, section can be null for global var
$smarty->assign($conf->get('mytheme.conf','mysection','myvar'));
Monte
Ivan Voras wrote:
"Monte Ohrt" <monte@ispi.net> wrote in message news:3CDA83CB.6020607@ispi.net... | Why? I would think that this is a benefit. this lets the template that is exactly what I am trying to avoid! I do not want to load config files from within templates! | control the config variables (the application doesn't need to deal with it.) The web site I need this for is very complex. It consists of numerous "modules" (i think "portlets" would be the current buzzword-name), which are all loaded from a central place (index.php), and each of the modules has its own template(s). All modules must adhere to the configuration/color theme/layout that is decided in that central place, and act accordingly. Config files would be really nice for dealing with color themes. And besides, there are numerous template writers, and I do not want to make them all revise every template on site, and insert that unnecessary[*] line every time they make a new one. [*] because I HAVE managed to do what I want (see original post), I am only searching for a more elegant solution :) -- ---- -------- - Ivan Voras <ivoras @ fer.hr> - - I modem, but they grew back. --- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc.