CodeIgniter Forums
Best place to put variables you need throughout the application - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Best place to put variables you need throughout the application (/thread-19815.html)



Best place to put variables you need throughout the application - El Forum - 06-19-2009

[eluser]lennierb5[/eluser]
Let's say you have information like $sitename = "Name of your site" and other information you might need on every page, where is the best place to put this information? I tried adding it to the config file which would make sense but could not access it in the controller.

Thanks in advance.


Best place to put variables you need throughout the application - El Forum - 06-19-2009

[eluser]TheFuzzy0ne[/eluser]
How did you add it, and how were you trying to access it?


Best place to put variables you need throughout the application - El Forum - 06-19-2009

[eluser]lennierb5[/eluser]
I added it as:

$config['s_sitename'] = "Site Name Here";

Then tried to call it as:

$config['s_sitename']


Best place to put variables you need throughout the application - El Forum - 06-19-2009

[eluser]n0xie[/eluser]
You can access it with :
Code:
$this->config->item('s_sitename');

Although personally I would load theses kinds of variables in MY_Controller and extend all my controllers from there.