Welcome Guest, Not a member yet? Register   Sign In
Do something on every page
#1

[eluser]FinalFrag[/eluser]
Hi there guys,

I'm working on this website and I have a problem.
I have a header.php file, which contains some code that has to be included on every page. This header.php also draws a menu on the screen.

At the moment, I have this in my controller
Code:
...
$data['menu'] = '<a href="#">home</a> | <a href="#">about</a>';
$this->load->view('home', $data);
...

In home.php I then include the header file which uses the $menu variable to draw the menu items.

The problem is that I have to define this $data['menu'] variable in ALL my controller (cause I need the menu on every page). Is there an easier way do this?

Cause in real life it's not as easy as $data['menu'] = ...
In real life, the data needs to be fetched from a database.

Is there any way for me to have the $data['menu'] variable in EVERY controller without me having to declare it all the time? (some kind of hook maybe?)

Thnx in advance...


Messages In This Thread
Do something on every page - by El Forum - 09-01-2008, 03:17 PM
Do something on every page - by El Forum - 09-01-2008, 05:34 PM
Do something on every page - by El Forum - 09-01-2008, 05:52 PM



Theme © iAndrew 2016 - Forum software by © MyBB