Reputation: 663
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)
Upvotes: 0
Views: 971
Reputation: 1330
I've order my menu group like that:
->firstly , you should have a specific group name that is easy to remember (dashboard, bill, ....) and make your configuration in config/services.yaml:
....
App\Admin\OrderAdmin:
arguments: [~, App\Entity\Order, App\Controller\ActionAdminController]
tags:
- { name: sonata.admin, manager_type: orm, group: dashboard, label: Orders }
App\Admin\RequestAdmin:
arguments: [~, App\Entity\Request, App\Controller\ActionAdminController]
tags:
- { name: sonata.admin, manager_type: orm, group: dashboard,label: Request }
App\Admin\clientAdmin:
arguments: [~, App\Entity\Client, App\Controller\ActionAdminController]
tags:
- { name: sonata.admin, manager_type: orm, group: dashboard,label: "client" }
App\Admin\BillAdmin:
arguments: [~, App\Entity\Bill, App\Controller\ActionAdminController]
tags:
- { name: sonata.admin, manager_type: orm, group: bill, label: 'Bill clients' }
public: true
App\Admin\DailyBillAdmin:
arguments: [~, App\Entity\DailyBill, App\Controller\ActionAdminController]
tags:
- { name: sonata.admin, manager_type: orm, group: bill, label: 'Daily Bills' }
App\Admin\OlderBillAdmin:
arguments: [~, App\Entity\OlderBill, App\Controller\ActionAdminController]
tags:
- { name: sonata.admin, manager_type: orm, group: bill, label: 'Older Bills clients' }
public: true
App\Admin\ConfigurationAdmin:
arguments: [~, App\Entity\Configuration, ~]
tags:
- { name: sonata.admin, manager_type: orm,group: configuration, label: 'Configuration Taxes' }
App\Admin\UserAdmin:
arguments: [~, App\Entity\User, App\Controller\ActionAdminController]
tags:
- { name: sonata.admin, manager_type: orm,group: users, label: 'User Management' }
.....
and after you can easily order your groupe name like this in config/packages/sonata_admin.yaml like:
sonata_admin:
title: 'Your Title'
dashboard:
blocks:
- { type: sonata.admin.block.admin_list, position: left }
groups:
dashboard:
label: DASHBOARD
bill:
label: BILLS
configuration:
label: CONFIGURATIONs
users:
label: USERS
......
and if you want to reorder the item into the group or not into the group you can use items options . here is the documentation for that : documentation
Upvotes: 0
Reputation: 1431
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
- ~
Upvotes: 0