Create a menu out of a parent-child relation table |
[eluser]yannyannyann[/eluser]
Hello, I have to do a navigation menu for my site that has pages organised in parent / child style. In my database I have a table that describes each line like this : Code: id_parent | id_child I php i get this array : Code: Array I would like to create a navigation menu out of this. How could I do so ? Example of my wished nav menu : Code: 1 THanks in advance for your help, cause I am a bit stuck here !
[eluser]Kyle Johnson[/eluser]
I ran into a problem like this too, sadly there is no great way to get around it (that I've yet come across). I did find this article (and saved it for later reference) because it provided two workable solutions. View it here. The thing I didn't like about the first approach was the necessity for submitting numerous queries to the server every time a menu was displayed. (Basically one query is submitted for each menu and then each submenu). Hopefully the tutorial / guide can help you out.
[eluser]slowgary[/eluser]
There are a lot of threads about this already. Search for 'hierarchical' or 'hierarchical menu'. Here's a thread I started about the topic: http://ellislab.com/forums/viewthread/110050/ Also, you could eliminate the need for that table and just store the parent id of an element within the element's row. For instance: Code: menu table Would represent a menu like this: Code: hello |
Welcome Guest, Not a member yet? Register Sign In |