简体   繁体   中英

Sonata Admin Custom Controller in Menu Override existing ones

I try to add a custom Controller/Page to the Knp Menu in Sonata Admin. I have bring it allready to work that the menu shows me the link in the navigation. I do it like this in the config:

    groups:
             User:
                  label:            User
                  items:
                      - route:        user_index
                        label:        User Profile
                      - route:        user_edit
                        label:        User Edit
                      - route:        user_password
                        label:        User Password
                  roles: [ ROLE_USER]

My Problem is my existing Sonata Admin Controllers are not shown in the menu when i activate this setting. What can i do to add and not override? What i found is to maybe register a listener and extend there the menu. But i found it must be easier than that.

What is the best way to do this? THX

I had the same problem and I solved it by adding an empty menu item with the same label as the default Sonata items (in my situation that group was called admin ):

sonata_admin:
    templates:
        # default global templates
        layout: SonataAdminBundle::layout.html.twig
    dashboard:
        groups:
            admin: ~
            User:
                label:            User
                items:
                    - route:        user_index
                      label:        User Profile
                    - route:        user_edit
                      label:        User Edit
                    - route:        user_password
                      label:        User Password
                roles: [ ROLE_USER]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM