Welcome Guest, Not a member yet? Register   Sign In
global variables
#1

[eluser]Uplift[/eluser]
I am new to code igniter and cant work something out.

Basically, in the header i have an ads section that i want to on every page load.

for this i am using an array

$ads = array(
"ad1 code...",
"ad2 code...",
"ad3 code...",
);

then returning it like this

$data['advertisements'] = random_element($ads);

the problem is the ads appear on every page and having this code in every controller will be a nightmare to update. how can i declare it globally?
#2

[eluser]osci[/eluser]
You would create a MY_Controller in application/core
put your desired code in there
and extend your controllers from MY_Controller and not CI_Controller

Check the user guide for extending controllers and in the forum you'll see many examples of MY_Controller.




Theme © iAndrew 2016 - Forum software by © MyBB