bmcclure / CakePHP-Menu-Plugin

A CakePHP 2.0 plugin designed to help build menus in the controller and display them in the view
MIT License
17 stars 9 forks source link

Support 'parent' option for auto-generated menus #4

Open bmcclure opened 12 years ago

bmcclure commented 12 years ago

When auto-generating a menu, it should check for a 'parent' option being specified and place the menu under that parent instead.

How this should be done is yet to be determined. Simplest would be to simply pass a Menu object or a MenuItem object in for the 'parent' option, however when using MenuBuilder you might not actually have the underlying Menu or MenuItem.

Using the name of the menu to add it to is easy, but then defining which item under that to use might be difficult unless I create better ways of finding existing menu items in the stucture.

Maybe a 'hasChild($name) on Menu would work well enough. to be able to loop through a menu and drill down to a specific item.

We could then add getChild($name) to traverse the tree and return the correct MenuItem.