For a recent project, I needed to include KnpMenuBundle in a Symfony2 project. This project was styled using the famous Twitter Bootstrap. I’ve found many articles describing how to do this but all of them didn’t exactly resulted in something I wanted: a web application with a navigation bar including icons and dropdown menu’s. In addition, I needed a “active” class indicating which item was visited, including parent/child items.
The files below belong to a tutorial which can be found here: http://nielsmouthaan.nl/symfony2-knpmenubundle-font-awesome-twitter-bootstrap-integration-navigation-bar-including-icons-and-dropdown-menus/
Thanks so much for this. I was searching through the knp docs and couldn't figure out how to modify just the template. I'm not sure when you posted this gist, but on
dev-master
(commit 7baf621fb77867e49daca7dd72b443ea232cb5e1) as of 9/3/2013, I was able to pass{ currentClass: 'active', ancestorClass: 'active' }
toknp_menu_render
to trigger TB active link highlighting on both the current item and its containing dropdown link. This lets me skip dealing with theRequestVoter
implementation.