5

I try to configure a custom admin menu in the sidebad of my Sonata Admin Bundle, but i don't understand how to ?

Thanks

Djoo

djoo
  • 685
  • 1
  • 7
  • 24

2 Answers2

9

The sidebar nav doesn't have a specific configuration, it uses the dashboard config to be generated.

To see it, you must be logged in and the user must have ROLE_SONATA_ADMIN to see the sidebar nav.

https://github.com/antoinemineau/SonataAdminBundle/blob/master/Resources/views/standard_layout.html.twig#L181

A related issue is explained here: https://github.com/sonata-project/SonataAdminBundle/issues/2321#issuecomment-52756483

HypeR
  • 2,186
  • 16
  • 22
  • 3
    ;_; why wont they update their damn documents, as a new user we have to scramble around to find the answers that they should have given – some_groceries Jan 27 '16 at 08:12
  • 1
    @Dheeraj, I know this response is late, but it's worth adding an answer. I'm not their maintainer and have only contributed issues, _but_, I will say that they are not the first FOSS project to request help from the community of developers who use their product to write docs. Symfony's recent development has been pretty heavy from v3-v4 and lot's changed, so Sonata Admin team has had to work to keep things working in new Symfony versions while also adding new features and fixing new bugs. I respect that they can't always get to docs and I respect them asking for help from the community. – John Pancoast Jul 16 '18 at 01:00
  • @JohnPancoast cringe at their internal process, documentation is an integral part of software development, how do they expect people to use their product – some_groceries Jul 16 '18 at 05:51
  • @Dheeraj, I agree that documentation is important for software development, but so is reading other's code. And much of their library is documented, including this answer which can be found here https://symfony.com/doc/master/bundles/SonataAdminBundle/reference/templates. They tell you where the base template is and from there you must read that template to understand what to override (and must understand twig inheritance). This question was a specific question with a specific answer and sonata cannot document every single use case like this one, but in general, this behavior is documented. – John Pancoast Jul 17 '18 at 18:23
0

For people that may be interested, a feature was added to manage the sidebar menu items (add or remove some of them) dynamically.

That mean you can easily have a condition based sidebar (i.e. display a different sidebar depending on (for instance) the role of the authenticated user).

The feature consists in an EventListener listening on a custom ConfigureMenuEvent using KnpMenuBundle.

See extending the menu (KnpMenu Recipe of the SonataAdmin documentation) and the related chapter of the KnpMenuBundle official documentation.

chalasr
  • 12,971
  • 4
  • 40
  • 82