Welcome Guest, Not a member yet? Register   Sign In
Suggestion for database driven navigation
#1

[eluser]FuzzyJared[/eluser]
I am building a CMS, and have started working on integrating the content categories as links within the fronend of the site. My question is what would be the best way to set this up. I could get all the links from the controller and pass it to the the template section via a $data['nav'] = ''; But this would mean calling the same thing in every page function within the controller. I would much rather call the request from template file such as left_col.php.

Any suggestions would be helpfull
#2

[eluser]Ryuuzaki92[/eluser]
make a library? you can autoload them and make a helper for it.
#3

[eluser]sergitin[/eluser]
Do those link come from a query at the database??
#4

[eluser]FuzzyJared[/eluser]
The links would generate from the database yes.
Basically I have Content Groups, Content Categories and then Content Pages.
The content groups are used to spit out the appropriate groups in the right area of the template, and then the categories are used to split up the grouping of content with <ul>'. And then the links are in <li> elements.

Producing the links are not hard, I was just looking for a better alternative to something like $data['info_nav'] = $this->get_info_nav(); and then feeding the data to the $data to the leftcol.php page that I have.
#5

[eluser]Rick Jolly[/eluser]
There are tons of things you can do. I'd start by putting the logic for the navigation in a library, and returning the navigation partial view as a string from that library. Then you could:
1) assign the partial view as a variable in each of your controller contstructors using $this->load->vars();
2) create an application/base/parent controller and do the same thing as in #1, but you'd only have to do it once.
3) create a helper that calls your library directly from the main layout view, so you wouldn't have to touch the controllers. For an example, search for hmvc on these forums.
#6

[eluser]FuzzyJared[/eluser]
Thank you for your advice. I will look into building a library as you suggested.




Theme © iAndrew 2016 - Forum software by © MyBB