well, if you want to use the automatic menu generated by sonata you can use this steps to reach the point:
Solution
override the default sonata layout twig file from config.yml
sonata_admin:
templates:
layout: ::layout.html.twig
your ::layout.html.twig
:
{% extends 'SonataAdminBundle::standard_layout.html.twig' %}
{% block side_bar_nav %}
{{ knp_menu_render('sonata_admin_sidebar', {template: sonata_admin.adminPool.getTemplate('knp_menu_template')}) }}
{% endblock %}
Why this solution?
since the default SonataAdminBundle::standard_layout.html.twig
checks the user to have the ROLE_SONATA_ADMIN
permission (and you might not using sonata user bundle
), you need to override permission checking process, which is by default:
{% block side_bar_nav %}
{% if app.user and is_granted('ROLE_SONATA_ADMIN') %}
{{ knp_menu_render('sonata_admin_sidebar', {template: sonata_admin.adminPool.getTemplate('knp_menu_template')}) }}
{% endif %}
{% endblock side_bar_nav %}
I think this is the easiest way to use navigation buttons on left sidebar.