Re: [SMARTY] Multiple Config Directories

From: Date: Tue, 11 Mar 2003 10:42:37 +0000
Subject: Re: [SMARTY] Multiple Config Directories
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-8546@lists.php.net to get a copy of this message
On Monday 10 March 2003 11:07, Hinrich Donner wrote: > I need access to multiple directories like $smarty->plugins_dir. Hi, I have implemented something simple that enables multiple configuration directories. At the moment I do not know if there are side effects. I create a class with constructor derived from Smarty. I implemented the following method: /** * Config Load * * This method overwrite the original Smarty method. It enables the use * of multiple configuration files. The directories are processed in * order they are stored in the array. * * @param string $file The file name located in one of the directories * @param string $section The section in the configuration file * @param string $scope The scope for the variables * @see Smarty::config_load() * @todo Look for side effects with Smarty. */ function config_load($file, $section = null, $scope = 'global') { // If we do not have an array, we can proceed the normal method. // if (!isset($this->config_dirs) || !is_array($this->config_dirs)) return parent::config_load(&$file, &$section, &$scope); // Now we have to move through the directories. // reset($this->config_dirs); foreach ($this->config_dirs as $config_dir) { $this->config_dir = $config_dir; parent::config_load(&$file, &$section, &$scope); } } To define the directories use (mind the last 's') $smarty->config_dirs = array('foo/', 'bar/'); In this case, the variable $smarty->config_dir wil NOT be processed! Hinrich -- Hinrich Donner

« previous php.smarty.general (#8546) next »