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

前端 未结 2 1827
傲寒
傲寒 2020-12-31 11:45

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 overridi

相关标签:
2条回答
  • 2020-12-31 12:06

    You can pass it like that:

    {{ knp_menu_render('AcmeDemoBundle:Builder:mainMenu', {'currentClass': 'active'}) }}
    
    0 讨论(0)
  • 2020-12-31 12:28

    To apply default options in all your application, you can set the knp_menu.renderer.twig.options parameter like this:

    // app/config/services.yml
    parameters:
        knp_menu.renderer.twig.options:
            currentClass: active
    

    Default options of the Knp\Menu\Renderer\TwigRenderer are:

        $this->defaultOptions = array_merge(array(
            'depth' => null,
            'matchingDepth' => null,
            'currentAsLink' => true,
            'currentClass' => 'current',
            'ancestorClass' => 'current_ancestor',
            'firstClass' => 'first',
            'lastClass' => 'last',
            'template' => $template,
            'compressed' => false,
            'allow_safe_labels' => false,
            'clear_matcher' => true,
            'leaf_class' => null,
            'branch_class' => null,
        ), $defaultOptions);
    
    0 讨论(0)
提交回复
热议问题