KnpMenuBundle - send Options and use them in Twig

后端 未结 2 835
慢半拍i
慢半拍i 2021-01-21 23:30

I wrote the last days on my nav-bar-menu whit KnpMenuBundle. I want simply to give the template a few parameters on the way and then react on it. Is it possible? I tried this:

2条回答
  •  别那么骄傲
    2021-01-22 00:07

    I don't know if this can still help but there's a much easier way to use font awesome with knp menu. There's an option where you can give a class to your link. You just need to create a child without a label an add setLinkAttribute. Ex:

    $menu
      ->addChild('', array('route' => 'backend_index'))
      ->setLinkAttribute('class', 'fa fa-home');
    

    This will create an "a" tag with the class fa fa-home. Even if Font Awesome documentation says the icons are designed for inline elements, it will work with "a" tag. You can then use some css to improve the design. In my case, I just changed font-size and line-height.

提交回复
热议问题