Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 2.0 KnpMenu custom template

Im trying to modify template from knpMenu. I renamed it to knp_main_menu.html.twig

config.yml:

knp_menu:
    twig:
        template: knp_main_menu.html.twig
    templating: true
    default_renderer: twig

knp_menu.html.twig works but my file (exact copy of the original) does not. Is there any way to do this?

My final goal is to make template that works with icons:

for example:

$menu->addChild('Grupy', array(
            'route' => 'group',
            'attributes' => array(
                'title' => 'Dodaj nową grupę',
                'data-icon' => 'group',
                'data-id' => 'groups_list',
            )
        ));

should produce something like this:

<ul>
    <li title="Dodaj nową grupę" data-id="groups_list" data-icon="group">
        <a href="...">
            <img src="somedir/group.png" /> Grupy 
        </a>
    </li>
</ul>
like image 693
Kaminari Avatar asked Feb 21 '23 18:02

Kaminari


1 Answers

this was quite simple:

{{ knp_menu_render('AlefDemoBundle:Builder:mainMenu', { 'template': 'AlefDemoBundle:Menu:knp_main_menu.html.twig' }) }}

inside twig template.

like image 98
Kaminari Avatar answered Mar 11 '23 20:03

Kaminari