0

With ...MyBundle\Resources\views\Menu\knp_menu.html.twig, deleting the </li> has no effect on the rendered menu. (Removing the tag is done to remove the space between inline list elements.) I have followed the advice provided in this answer, including the {% import 'knp_menu.html.twig' as knp_menu %} mentioned toward the bottom of that post. Is this because knp_menu.html.twig already extends knp_menu_base.html.twig? Or what?

layout.html.twig:

...
{{ render(controller('VolVolBundle:Default:userMenu')) }}
...

userMenuAction:

$user = $this->getUser();
$tool = $this->container->get('vol.toolbox');
$type = $tool->getUserType($user);
return $this->render(
                'VolVolBundle:Default:userMenu.html.twig', array('type' => $type)
);

userMenu.html.twig

...
{% if type is not null %}
    {% set menu = "VolVolBundle:Builder:"~type~"Menu" %}
    {{ knp_menu_render(menu) }}
{% endif %}
Community
  • 1
  • 1
geoB
  • 4,578
  • 5
  • 37
  • 70

1 Answers1

0

The answer was found deep in here. All that's required to do a global override of the template is to modify config.yml.

config.yml:

...
knp_menu:
    twig:  # use "twig: false" to disable the Twig extension and the TwigRenderer
        template: VolVolBundle:Menu:knp_menu.html.twig
...
geoB
  • 4,578
  • 5
  • 37
  • 70