Re: multiple config dirs

From: Date: Thu, 13 Mar 2003 14:00:51 +0000
Subject: Re: multiple config dirs
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-8616@lists.php.net to get a copy of this message
Hi, It would be greate if the Smarty developers would post any comments on Hinrich Donner's implementation to handle multiple config dirs. atur ----------------------- Hinrich Donner wrote: 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 (#8616) next »