Change content of the SonataAdminBundle left menu
Par Alexis Lefebvre le dimanche 15 février 2015, 21:36 - Lien permanent
I searched a solution for about half an hour, although the configuration is detailed in the official documentation. Here is how to configure the left menu of SonataAdminBundle 2.3.
Add this to the app/config/config.yml file
:
sonata_admin: # Override default template templates: layout: AcmeAdminBundle::standard_layout.html.twig
Then create the standard_layout.html.twig
file in src/AcmeAdminBundle/Resources/views
:
{# src/Acme/AdminBundle/Resources/views/standard_layout.html.twig #} {% extends 'SonataAdminBundle::standard_layout.html.twig' %} {% block side_bar_after_nav %} <p class="text-center"><a href="{{ path('your_route') }}">Route name</a></p> {% endblock %}
You can also add a list of links with <ul><li><a href="…">…</a></li></ul>
, etc.
Alternative path
The Twig file can also be placed outside of a bundle, in app/Resources/views
:
sonata_admin: # Override default template templates: layout: "::standard_layout.html.twig"
Then create the standard_layout.html.twig
file in app/Resources/views
:
{# app/Resources/views/standard_layout.html.twig #} {% extends 'SonataAdminBundle::standard_layout.html.twig' %} {% block side_bar_after_nav %} <p class="text-center"><a href="{{ path('your_route') }}">Route name</a></p> {% endblock %}