php,css,symfony2,knpmenubundle
$menu->addChild('agb', array('uri' => '#')) ->setAttribute('divider_append', true) ->setLinkAttribute('class', 'childClass'); easy as that :)...
php,html,symfony2,knpmenubundle
What does raw do? By default, when displaying something in Twig (using {{ }}), Twig will escape it to make sure it's safe. We don't want any evil HTML ending up in our pages. Sometimes the thing we want to display is already HTML, so we don't want to escape...
You'll need to edit your menu templates. There is some good documentation about how to do that.
php,symfony2,knpmenubundle,knpmenu
You can add any attribute you want with $menu->addChild('Dashboard', array( 'route' => 'admin_dashboard', ))->setAttribute('icon', 'icon-class'); then {{ item.attribute('icon') }} ...
Following the tutorial exactly, this error is caused by line 25 in the file 2 // src/Acme/MainBundle/Menu/MenuBuilder.php ... 25 $menu->addChild('Home', array('route' => 'homepage')); The tutorial code assumes that you have a route called 'homepage'. Assuming you set this up inside a custom Bundle, then a quick way to solve this...
You can pass it like that: {{ knp_menu_render('AcmeDemoBundle:Builder:mainMenu', {'currentClass': 'active'}) }} ...
If you want to give a class to li elements, you have to set it this way: $menu->addChild('Label', [ ... 'attributes' => ['class' => 'sf-menu'], ]); If you want to give a class to your ul element: $menu = $this->factory->createItem('root'); $menu->setChildrenAttribute('class', 'sf-menu'); ...