Welcome Guest, Not a member yet? Register   Sign In
Dynamic site structure?
#1

[eluser]neverstop[/eluser]
Hello, i'm developing a site with CI and i'm having a lot of issues because i need to build it with 2 menus. The first one is a top menu and the other a left menu, like this:

Quote: [home] [products] [support] [about]

[Grano series]
[AL Series]
[Ponto Series] ... etc
I'm thinking how to create the best architeture to my site. I was looking at the CI examples on the internet and i didn't find a dynamic menu application working with CI. Well..my first idea was create a new controller to every menu item, "home.php", "products.php", "support.php" and "about.php", and inside every file my functions. When i access a controller, "products.php" for example i should have a index() function that creates the left menu and so goes to all controllers. I'll have a controller to evey page and its functions to create the pages when i click on the left menu. Yehhh looks great no? I think developers build simple sites using these ideas no?

But my site is much more complicated and i need a dyncamic menu that will be create getting values of a database. The top menu should be associated to the left menu ...did you get the idea? I allways built sites without any framework and now i look to CI and i dont know what to do...everything i see its that i MUST create a new controller to every page and functions with parameters to load its content. May someone open my mind to CI? A dynamic example menu working with a database should be great! Thanks ^^
#2

[eluser]Eric Barnes[/eluser]
I am not saying this is the best way but I would probably build a navigation table and have each element reference another. For example:

Code:
ID | Parent | Name |
1 0 Home
2 0 About
3 2 Sub Page under about
4 0 FAQ
5 4 FAQ Sub Page

Then you can just iterate through to get the side bar and navigation bar.
#3

[eluser]jabre[/eluser]
I took the nested sets approach described in this wiki-entry: http://codeigniter.com/wiki/Nested_sets/
and this forum-thread: http://codeigniter.com/wiki/Nested_sets/

If you use the nested sets model and extend it with your own, you can get nearly every type of dynamic menu.




Theme © iAndrew 2016 - Forum software by © MyBB