Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Access to Config Vars in Plugins

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
MichaelLS
Smarty n00b


Joined: 02 Jun 2004
Posts: 2

PostPosted: Wed Jun 02, 2004 1:15 pm    Post subject: Access to Config Vars in Plugins Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Jun 02, 2004 1:28 pm    Post subject: Re: Access to Config Vars in Plugins Reply with quote

MichaelLS wrote:
First I used the undocumented method
get_config_vars($name=null)


undocumented?

http://smarty.php.net/manual/en/api.get.config.vars.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Jun 02, 2004 1:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP