Welcome Guest, Not a member yet? Register   Sign In
Best approach(es) to implementing site navigation
#1

[eluser]Fred Riley[/eluser]
I'm a 'faux beginner' at CI, having written a few prototype apps but not deployed anything as yet. My question relates to approaches to structuring a CI site, hence posting to this forum rather than the code forum.

What are the best approach(es) to implementing a hierarchical multi-level website navigation system in CI?

What I'm trying to implement is online as a draft static design. Follow the path Support => Rapid E-Learning to see second and third level menus. I can see various ways to implement the menu system I'm after, from simple copying and pasting menu <nav>s into different views, to creating constants with menu items+urls, to putting the menu items into a database, to putting the menu items into includes. This must be a common enough thing in CI sites, so I'd be grateful for pointers to different approaches that folk here have used. I expect that there should be just one file defining the menu items, but I'm not into the 'CI way' enough yet to be sure where I should stick it and what should be in it.

Where I've looked
Bearing in mind the strictures in How to ask a good question</a>, and to try to counter RTFFAQ and RTFM replies, I've looked at the following forum posts and docs:

1
2
3
FAQ
Video tutorials

and have used the following terms in a forum search:

hierarchical menu system
menu system
site navigation

I've also tried Google with similar terms, adding 'codeigniter', but although I've hit some interesting docs they seem to concentrate too much on the trees whereas I'm after a wood overview Wink

TIA for any helpful tips.

Fred
#2

[eluser]ripken204[/eluser]
I have not looked at your links...
but the common way is to put the html in the header file.

you really should have a header and a footer file
that way if you need to change something in the header, you only have to change it once

the only reason to put it into a database is if you want to be able to add menu items from your application instead of hard coding the menu items.

#3

[eluser]Fred Riley[/eluser]
Thanks for the reply. I have set up header and footer views, and the top level menu appears in the header. However, my design is that the second and third-level menus will appear in the page body text - see this page which has all 3 navs visible

So the clunky approach would be to have a view for each of the top level sections, with a different subnav in each, but that would lead to update problems as the site grows. Hence my thinking that the menu items for all navs should be defined just once, perhaps as an array constant. If I went that way, where is it best to put global constants? In /libraries, perhaps, or /config?

Cheers

Fred




Theme © iAndrew 2016 - Forum software by © MyBB