Welcome Guest, Not a member yet? Register   Sign In
Way to get a config value from a helper
#1

[eluser]earlyriser[/eluser]
Inside a helper, $this->config->item('item name'); doesn't work.

Is there a way to fetch a config value from there? Without passing the value as a function parameter.

Thanks
#2

[eluser]danmontgomery[/eluser]
$this doesn't work at all because helpers aren't class methods.

Code:
$CI =& get_instance();
$value = $CI->config->item('item_name');
#3

[eluser]earlyriser[/eluser]
Thanks noctrum. I wasn't sure about that.
#4

[eluser]janogarcia[/eluser]
You could even do this

Code:
$value = config_item('item_name');

If you don't need access to the CI super object, the global function config_item() (defined in Common.php) comes in very handy.
#5

[eluser]cahva[/eluser]
Yeah I use the config_item() all the time. Its shorter, sweeter and works everywhere Smile




Theme © iAndrew 2016 - Forum software by © MyBB