PHP menu with collapse/expand feature? |
[eluser]PoWah[/eluser]
Im stuck with this function I think for about a week :down: Could anyone share the code for generating treelike menu with expand feature (i mean when a user clicks on a menu item, then this item shows its children items)? I saw Dynamic menu in the wiki but it seems to be not dynamic In a database I have these fields: id, parent_id, id_hierarchy (like "1.15.17", ids separated with dot), alias, menu_text and content. It would be wonderful if I could prevent recursion but if not it would be great anyway... :-) Anyone? :red:
[eluser]gunter[/eluser]
I guess you want a out of the box php solution... but here is an example for the do-it-yourself people: http://developer.yahoo.com/yui/treeview/
[eluser]PoWah[/eluser]
No, I want a solution completely only in php, no javascript.
[eluser]huggiebear[/eluser]
If you use php solely then you'll have to reload the page each time. Regards Huggie
[eluser]Michael Wales[/eluser]
Yep - PHP is server-side and the server only talks to the client when the client asks for it (ie. asking for a page / refreshing). Unless you want to reload the page everytime, you should really use some JavaScript in there. Besides, YUI is freaking awesome x 2.
[eluser]PoWah[/eluser]
guys dont laugh at me :-) i know that every time page will reload - that is what i exactly need at this time.. pure php menu.. javascript i will add later
[eluser]PoWah[/eluser]
I simply do not believe that nobody has such script .. guys drop it here! ;-)
[eluser]mmm_broccoli[/eluser]
just have your menu links call a controller that deals with keywords passed via the url. such as "contact" "zoo". and then have some function/class build the required menu.. then output.
[eluser]Michael Wales[/eluser]
Here's how I would do it, in a simple list: - Use uri->segment() functions to pass the current controller/method to a Menu model - The Menu model will receive these parameters and return a multi-dimensional array, consisting of the entire menu, going into further detail (ie. another dimension of the array), for the controller/method that is selected - The controller will iterate over the array, returned from the model, to output the XHTML that will build your tree.
[eluser]PoWah[/eluser]
all the logic I knew before writing to the forum. Im stuck with the menu html formation code. As walesmd says: "iterate over the array, returned from the model, to output the XHTML that will build your tree." |
Welcome Guest, Not a member yet? Register Sign In |