Re: [SMARTY] Using PHP variables in smarty control structures
| From: | Brodie Thiesfield | Date: | Wed, 02 Oct 2002 03:03:29 +0000 |
| Subject: | Re: [SMARTY] Using PHP variables in smarty control structures | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6067@lists.php.net to get a copy of this message | ||
Hi,
I found a solution, although not a very clean one. I have had to modify the Smarty class to make this work...
At the very beginning of the Smarty class definition, add...
/* BRO START */
var $bro_config_files = array();
function bro_add_config_file( $config_file, $section = '' )
{
if ($config_file != '' )
{
$this->bro_config_files[$config_file] = $section;
}
}
/* BRO END */
Then in the fetch function (with the context given) add the following...
/* Initialize config array. */
$this->_config = array(array('vars' => array(),
'files' => array()));
/* BRO START */
/* pre-assigned config files */
foreach( $this->bro_config_files
as $bro_config_file => $bro_config_section )
{
$this->_config_load( $bro_config_file,
$bro_config_section, "local" );
}
/* BRO END */
if (count($this->autoload_filters))
$this->_autoload_filters();
I can now call this using the following in my main php file...
$smarty->bro_add_config_file( "index.cfg", $lang );
$smarty->display( "index.tpl" );
If there is a better (cleaner - no code changes) way of doing this, please let me know.
Cheers,
Brodie.