Tree Helper to generate Twitter Bootstrap navigation 'ul' list #58

netstyler opened this Issue Dec 17, 2012 · 9 comments

6 participants


I have a threaded find result which I do pass to the helper.
The helper should help me to generate a navigation like it is shown here:


I tried to get it work with a node element which looks like this:
Also a var_export array is given to test.

The problem is, that the vars $firstChild and $lastChild always do give me boolen true back on each child item so that I can't figure out if the child ist the last item of the dropdown menu to close it with a closing ul tag.

A other solution would be to extend the helper code to pass the needed class defintion for the nested ul list as a second argument. At the moment the main ul and li class can be defined but the list is basicly correctly generated by the helper.


Changing the behaviour of a helper to fit a specific front-end framework is not productive and will reduce the overall helpfulness of the helper to others not using your chosen front-end framework.

I would suggest either creating your own helper or extending the CakeDC one.


Here is a method for bootstrap nav

You dont need to know if its first or last in the list. Just a recursive function will do.

I don't think this repo should contain bootstrap related features any how. There are already a number of full featured bootstrap plugins for CakePHP available.


Thx to all the feedback. Will checkout your MenuHelper dogmatic.


dear netstyler, did you do writing the bootstrap nav with TreeHelper?


cybercoder: Yes we use Treehelper to display the bootstrap Menu. We needed to extend the Utile Tree Helper to be able to use bootrap nav properly. We did overwrite the _attributes method to set all needed classes by depth


Like netstyler said, this can be done by extending the helper and overwriting the _attributes() method to generate the elements and classes as you want them to be.

@burzum burzum closed this May 13, 2014

@faiyazalam It compatibles with bootstrap 2.x only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment