Welcome Guest, Not a member yet? Register   Sign In
Best place to put variables you need throughout the application
#1

[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.
#2

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

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

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

Then tried to call it as:

$config['s_sitename']
#4

[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.




Theme © iAndrew 2016 - Forum software by © MyBB