Questions tagged [knpmenubundle]

The KnpMenuBundle integrates the KnpMenu PHP library with Symfony2.

The KnpMenuBundle integrates the KnpMenu PHP library with Symfony2.

Once is integrated with Symfony, you can use 2 differents ways to build a menu:

  1. the "easy" way (basically the same as KnpMenu when using it as a stand alone library)
  2. and the more flexible method using a service.

Useful links:

122 questions
45
votes
5 answers

Customize the KnpMenuBundle

How to customize KNPMenuBundle? I can't figure out how to add an image or a span tag using the KnpMenuBundle. I simply want this:
  • My Title
Mick
  • 30,759
  • 16
  • 111
  • 130
12
votes
3 answers

How to disable HTML escaping of labels in KnpMenuBundle

I want to render an HTML label like: $menu->addChild('Dashboard', array( 'route' => 'dashboard', 'label' => ' Dashboard', 'extra' => array('safe_label' => true) …
Bartosz Rychlicki
  • 1,918
  • 3
  • 20
  • 41
11
votes
4 answers

Add Class to knp menu root Element with Twig

what is the correct way to add a class to knp_menu's root element
    with twig? i tried a lot of things: 1. {{ knp_menu_render('main', {'class': 'foo'}) }} 2. {{ knp_menu_render('main', {'attributes': {'class': 'foo'}}) }} 3. {{…
hereandnow78
  • 14,094
  • 8
  • 42
  • 48
11
votes
2 answers

How to change the "current" class to "active" in KNPMenuBundle

I was wondering, what is the best way to change the "current" class to be "active" so Bootstrap will work correctly with it? I thought about copying and overriding the knp_menu_html.twig but i think its not the best way... Anyway better doing it?
doron
  • 1,508
  • 3
  • 18
  • 27
9
votes
3 answers

Call to method setCurrentUri fails in Symfony/SonataUserBundle setup

I am trying to set up Symfony with the SonataUserBundle. User registration and login works fine. When I try to call up the /profile view, however I get the following error: Attempted to call method "setCurrentUri" on class "Knp\Menu\MenuItem" in…
matt_jay
  • 1,241
  • 1
  • 15
  • 33
8
votes
2 answers

KnpMenuBundle and dynamic route parameter

i use knpmenubundle for my website and here is my problem : i've a list of user listed by this route : /admin/users and the menu is like this : User (is opened) list (is active) add new in the list view, the item "list" in the menu is…
Chuck Norris
  • 1,125
  • 1
  • 12
  • 28
8
votes
2 answers

knpmenubundle: How to get user data in builder?

How can I get User data in theKnpMenuBundle's Builder? I know I can get the user data via this line in Controller: $user = $this->get('security.context')->getToken()->getUser(); but I want it to get in my menu builder aswell, so I can put the…
NaGeL182
  • 894
  • 1
  • 13
  • 35
8
votes
2 answers

Knp Menu Bundle Current item Symfony 2

I have a question regarding rendering the KnpMenu Bundle for Symfony2. From I've read, there should be a "current" class at the matched route item. I've read the Knp documentation and they're saying something about RouteVoter but I can't make it…
acid
  • 2,099
  • 4
  • 28
  • 41
6
votes
1 answer

Symfony 2 KNP Menu: add CSS class to link

I'm using the KnpMenuBundle for Symfony2 and I couldn't find a way to add a css class to the from the Menu generated links. What I tried to set the class to the child attribute, but that will not be given to the link but to possible children menus…
KhorneHoly
  • 4,666
  • 6
  • 43
  • 75
6
votes
3 answers

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

I want to my view code looks like this:
  • Title
  • I create menu elements by Menu Builder: class Builder extends…
    klapaucius
    • 111
    • 3
    • 11
    6
    votes
    2 answers

    Check if function/extension is defined

    In my Symfony2 bundle, I need to check if a function (an extension) is defined. More specifically, if the KnpMenuBundle is installed I use that one in my bundle, otherwise I will render the plugin myself. I tried this, but this of course doesn't…
    Wouter J
    • 41,455
    • 15
    • 107
    • 112
    6
    votes
    1 answer

    symfony2.1 bundle version confusion, for symfony and sonata admin / knp menu bundle

    I want to use symfony2.1 for a new project. I try to install symfony2 with composer. But there were multiple errors/problems and so I have also questions for each problem in bold font style. Sometimes I don't know if I do it the right way. I want to…
    timaschew
    • 16,254
    • 6
    • 61
    • 78
    5
    votes
    3 answers

    KnpMenuBundle not working with Bootstrap 4 navbar

    I am currently making a menu with the Symfony bundle: KnpMenuBundle. I am using Bootstrap 4 as stylesheet. Bootstrap 4 requires each list item in the navbar to have the class 'nav-item':
    5
    votes
    2 answers

    Configure Menu in Sonata Admin Bundle

    I try to configure a custom admin menu in the sidebad of my Sonata Admin Bundle, but i don't understand how to ? Thanks Djoo
    djoo
    • 685
    • 1
    • 7
    • 24
    5
    votes
    4 answers

    Symfony2 KnpMenuBundle: set active a menu item even when its not on that menu

    I created my menu builder and it works. One of my route is /database But this has a child route: database/view/{id} I don't want to put the view route into the menu items because without the ID it won't work. But I want the database route to be…
    NaGeL182
    • 894
    • 1
    • 13
    • 35
    1
    2 3
    8 9