Loading some data from database for all views in an application

#1
[eluser]Nameless One[/eluser]
I'm building a website which will have a navigation bar with some items "hardcoded" in the view and some links to static pages that will be defined in the database. Since the navigation bar will be displayed on every page, I need those few database rows in every view so that I could insert them as items in the navigation ul element.

Is there any way to do this without fetching those rows in every controller action?

#2
[eluser]InsiteFX[/eluser]
Yes.

Create a MY_Controller in application/libraries then add your code to that and extend that controller in all of your other controllers.

You can fnd the information for this in the users guide.

Enjoy
InsiteFX

#3
[eluser]Nameless One[/eluser]
That's for the suggestion. I've already come to the same conclusion myself. Wish there was some more elegant way in CI, like a support for HMVC for example.

#4
[eluser]Flemming[/eluser]
HMVC

:-)

it's very easy to set it up!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.