Well, if you want to use the automatic menu created by the sonata, you can use these steps to reach the point:
Decision
override default sonata twig file with 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 is this decision?
since by default SonataAdminBundle::standard_layout.html.twig checks the user for ROLE_SONATA_ADMIN permission (and you cannot use sonata user bundle ), you need to redefine the rights check 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 the navigation buttons on the left sidebar.
Aien saidi
source share