Welcome Guest, Not a member yet? Register   Sign In
Best Practice for Dynamic Navigation, Auto-Load Override
#1

[eluser]Unknown[/eluser]
I have some code that queries a database to collect and set up the hierarchy for site navigation, but I'm having trouble figuring out where I should put, and what form it should be in (model, library, helper, etc).

I figured a view or a controller would be inappropriate for it, since it should be available anywhere from the entire site, and a model might work even though those aren't supposed to output html directly, but my concepts for libraries and helpers are a bit more nebulous and I'm just not sure how this relatively minor function fits in.

Is it common (or rather, good) practice to set up a model similar to a registry that gets auto-loaded, in order to store variables and functions that're needed across the site?

Lastly, let's say I autoload sessions, database, and a few other models. Is there any way, in a controller, to override that list and choose to rebuild that list for that specific controller?

Thanks in advance!
#2

[eluser]bretticus[/eluser]
Sounds like this is a good candidate for a library to me.

You can load it in your controller (even your constructor) or simply autoload it from config/autoload.php. Since it's an instantiated object, you can expose some class properties for modifications before sending the output to your views.
#3

[eluser]umefarooq[/eluser]
for me now a days to solve this all problems better options is widget plugin really easy use and create every widget has its own separate view you can create menu widget, other part of your page left, right, top, bottom widgets, it works same like controllers have look on it if you have any problem just ask.

http://ellislab.com/forums/viewthread/109584/




Theme © iAndrew 2016 - Forum software by © MyBB