-
-
Save Gregoire-M/4585334 to your computer and use it in GitHub Desktop.
Modified menu template to handle submenus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Linkofy\CommonBundle\Menu; | |
use Knp\Menu\FactoryInterface; | |
use Symfony\Component\DependencyInjection\ContainerAware; | |
class Builder extends ContainerAware | |
{ | |
public function mainMenu(FactoryInterface $factory, array $options) | |
{ | |
$menu = $factory->createItem('root'); | |
$menu->setChildrenAttribute('class', 'nav pull-right'); | |
$menu->addChild('User') | |
->setAttribute('dropdown', true); | |
$menu['User']->addChild('Profile', array('uri' => '#')) | |
->setAttribute('divider_append', true); | |
$menu['User']->addChild('Logout', array('uri' => '#')); | |
$menu->addChild('Language') | |
->setAttribute('dropdown', true) | |
->setAttribute('divider_prepend', true); | |
$menu['Language']->addChild('Deutsch', array('uri' => '#')); | |
$menu['Language']->addChild('English', array('uri' => '#')); | |
return $menu; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ knp_menu_render('LinkofyCommonBundle:Builder:mainMenu', {'currentClass': 'active'}) }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank so much for this! Finding this was such a time saver!