CodeIgniter Forums
how can i use data from custom config in custom helper file - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: how can i use data from custom config in custom helper file (/showthread.php?tid=7490)



how can i use data from custom config in custom helper file - El Forum - 04-11-2008

[eluser]DanTyan[/eluser]
Hello

i need to use data from custom config in my helper file, is anybody know how i can do it?

now my code looks like this:
Code:
$this->config->load('compass');
$this->load->helper('design');

and in helper i need
Code:
function image($sImageName)
{
    return base_url() . $this->config->item('images', 'design') . $sImageName;
}

any ideas?


how can i use data from custom config in custom helper file - El Forum - 04-11-2008

[eluser]gon[/eluser]
You must get a reference to the CI object.

Code:
function image($sImageName)
{
    $CI =& get_instance();
    return base_url() . $CI->config->item('images', 'design') . $sImageName;
}

the same thing occurs in libraries and models.

cheers.


how can i use data from custom config in custom helper file - El Forum - 04-11-2008

[eluser]DanTyan[/eluser]
great!!!! thanks =)