|
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 |
MichaelLS Smarty n00b
Joined: 02 Jun 2004 Posts: 2
|
Posted: Wed Jun 02, 2004 1:15 pm Post subject: Access to Config Vars in Plugins |
|
|
Hi,
just donŽt know if IŽll get any problems with this solution,
but I had to get access to the vars which are configured
by an configfile. First I used the undocumented method
get_config_vars($name=null) but got problems with insert-Plugins.
So I derived a class from smarty and implemented following code:
[php:1:edecb0d0d4]<?php
/**
* returns the Value of a Var configured by an config-file
* @access public
* @param string $Name
* @param string $file=null
* @param string $section=null
* @param string $scope='global'
* @return mixed
*/
function getConfigVarValue($Name,$file=null,$section=null,$scope='global')
{
$RetValue = null;
if(array_key_exists(0,$this->_config)
&& array_key_exists("vars",$this->_config[0])
&& array_key_exists($Name,$this->_config[0]["vars"]))
$RetValue = $this->_config[0]["vars"][$Name];
elseif (!is_null($file))
{
$this->config_load($file,$section,$scope);
if(array_key_exists(0,$this->_config)
&& array_key_exists("vars",$this->_config[0])
&& array_key_exists($Name,$this->_config[0]["vars"]))
$RetValue = $this->_config[0]["vars"][$Name];
} // elseif (!is_null($file))
return $RetValue;
}
?>[/php:1:edecb0d0d4]
I would appreciate it, if anyone with more experience on smarty would comment this.
Greets
Michael |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Jun 02, 2004 1:31 pm Post subject: |
|
|
hee hee, messju beat me to it--I was just about to post the doc url. Anyhow, what is going wrong for you? You may have to do a manual $smarty->config_load if you are using insert since insert doesn't get the same conditions (as it is coming from a cache image) than a non-cached production of your page. |
|
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
|