Welcome Guest, Not a member yet? Register   Sign In
place for a common display function
#1

[eluser]Unknown[/eluser]
I'm thinking about the best solution now for days, and i can't figure out the best solution. I've searched this board and didn't find anyting usefull, so i finally ask the question here.

I have a tab based site design. Every tab is sort of a category and can have different child-category's which can have several child pages. I've made a dynamic menu to make this possible and i've stored the url's in a DB and in order to find wich page to display i need to figure out de page id. So on every page i have some common code to execute in order to figure out the current page and wich tab this page belongs to, in oder to make it 'active' in the design.

The question is what is the best location to store the general code. I've tried several things and i would like to hear your opinions.

Thanks in advance,
Kilian
#2

[eluser]tonanbarbarian[/eluser]
In this case because the code is really only ever displayed in a view then I would create a helper or plugin.
Having said that because you want the data to come from the database then what i do in the helpers is use get_instance to get an instance of the CI, then I would load a library and call a method in the library to get the data.

The reason I prefer to put this into a library is because
1. it is accessing the database,
2. i do not like complex code in my helpers

Yes it means I more code file having to be parsed and processed but I prefer to move things like this into libraries.
It means that most of my complex code is either in controllers, models or libraries
Where possible I keep my helpers and plugins as wrappers for library methods

but that is just me




Theme © iAndrew 2016 - Forum software by © MyBB