Welcome Guest, Not a member yet? Register   Sign In
PHP menu with collapse/expand feature?
#1

[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 Smile

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:
#2

[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/
#3

[eluser]PoWah[/eluser]
No, I want a solution completely only in php, no javascript.
#4

[eluser]huggiebear[/eluser]
If you use php solely then you'll have to reload the page each time.

Regards
Huggie
#5

[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.
#6

[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
#7

[eluser]PoWah[/eluser]
I simply do not believe that nobody has such script .. guys drop it here! ;-)
#8

[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.
#9

[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.
#10

[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."




Theme © iAndrew 2016 - Forum software by © MyBB