Menu
  • HOME
  • TAGS

Symfony 2 KNP Menu: add CSS class to link

php,css,symfony2,knpmenubundle

$menu->addChild('agb', array('uri' => '#')) ->setAttribute('divider_append', true) ->setLinkAttribute('class', 'childClass'); easy as that :)...

KNP Menu Bundle with HTML Special Chars

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

KNP Menu Bundle Translation Domain

symfony2,knpmenubundle

You'll need to edit your menu templates. There is some good documentation about how to do that.

KnpMenuBundle - how can i set an icon class to each elements of menu?

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') }} ...

Symfony2 KnpMenuBundle - Following tutorial and came across this error

symfony2,knpmenubundle

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

How to change the “current” class to “active” in KNPMenuBundle

symfony2,knpmenubundle

You can pass it like that: {{ knp_menu_render('AcmeDemoBundle:Builder:mainMenu', {'currentClass': 'active'}) }} ...

setAttributes method of KnpMenuBundle doesn't work

symfony2,twig,knpmenubundle

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'); ...