CodeIgniter Forums
Accessing the $config array from my custom helper - 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: Accessing the $config array from my custom helper (/showthread.php?tid=22936)



Accessing the $config array from my custom helper - El Forum - 09-24-2009

[eluser]Fabdrol[/eluser]
Hi guys!

I've written some extra helper functions inside my system/helpers folder. It contains some lifeline functions for my application.

Now, Since the app will run on different hosts later on, I want to keep control of every asset folder, and I defined them in my custom $config array.

Using
Code:
$this->config->item('icon_path');

the system generates the following error:
Code:
Fatal error: Using $this when not in object context in /Users/Fabian/Sites/Dyn4/app/system/helpers/dynamics_helper.php on line 21

My conclusion is, the $this pointer doesn't point to the CI object from the helper. (which isn't that strange)

Q: Is there a way that I can access the $config array from the helper?

thanks in advance!


Accessing the $config array from my custom helper - El Forum - 09-24-2009

[eluser]umefarooq[/eluser]
you can use in you helper

Code:
$ci = & get_instance();
  $ci->config->item('icon_path');



Accessing the $config array from my custom helper - El Forum - 09-24-2009

[eluser]Fabdrol[/eluser]
Thank you umefarooq!