symfonysonata-adminknpmenubundle

Custom order for elements on Admin Sonata left sidebar


I'm trying to make the left side to have a custom order (not alphabetical). I have more Bundles and for each bundle I have a custom services.yml. In each .yml I have the order that I want, but Sonata makes a custom order (A-Z) for each group. How it's possible to give a current index order ? I don't want to put all code into app/config/services.yml

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: services.yml }
    - { resource: currencies.yml }
    - { resource: '@XYZBundle/Resources/config/services.yml' }

XYZBundle/Resource/config/services.yml content:

services:
    xyz.admin.entity.one:
        class: XYZBundle\Admin\EntityAdmin_1
        arguments: [~, XYZBundle\Entity\Entity_1,  AppBundle:CRUD]
        tags:
            -
                name: sonata.admin
                manager_type: orm
                label:  Entity One
                audit: true
        public: true
    xyz.admin.entity.two:
        class: XYZBundle\Admin\EntityAdmin_2
        arguments: [~, XYZBundle\Entity\Entity_2,  AppBundle:CRUD]
        tags:
            -
                name: sonata.admin
                manager_type: orm
                label:  Entity Two
                audit: true
        public: true
    xyz.admin.entity.three:
        class: XYZBundle\Admin\EntityAdmin_3
        arguments: [~, XYZBundle\Entity\Entity_3,  AppBundle:CRUD]
        tags:
            -
                name: sonata.admin
                manager_type: orm
                label:  Entity Three
                audit: true
        public: true

And app/config/config.yml

sonata_admin:
    dashboard:
       groups:
          loan.admin:
              label: Custom XYZ
              icon: '<i class="fa fa-dollar"></i>'
              items:
                  - xyz.admin.entity.one
                  - xyz.admin.entity.two
                  - xyz.admin.entity.three

This is how it looks. (Confidential entity names)


Solution

  • sonata_admin:
        templates:
            # default global templates
            layout:  SonataAdminBundle::layout.html.twig
        title_logo: images/logo.png
        title: Your title
        dashboard:
            groups:
                identifier.for.this.group:
                    label:           Your Label
                    icon:            '<i class="fa fa-globe"></i>'
                    items:
                        - sonata.admin.service_name
    

    The service is the standard one for sonata

    sonata.admin.service_name:
        class: AppBundle\Admin\YourSonataAdminClass
        tags:
            - { name: sonata.admin, manager_type: orm, label: "Your Label" }
        arguments:
            - ~
            - AppBundle\Entity\AsociatedEntity
            - ~