如何使用 sonata admin 创建自定义列表
how to create custom list with sonata admin
我找不到(理解)如何将项目和类别添加到左侧管理菜单。
没有详细的教程如何做到这一点。
我可以将项目添加到 sonata.admin.block.admin_list 但放在管理菜单旁边
enter image description here
您需要在路由中添加一条路线:
admin.blog_post:
class: db306\CoreBundle\Admin\BlogPostAdmin
arguments: [~, db306\CoreBundle\Entity\BlogPost, ~]
tags:
- { name: sonata.admin, manager_type: orm, group: Content, label: Blog post }
public: true
admin.category:
class: db306\CoreBundle\Admin\CategoryAdmin
arguments: [~, db306\CoreBundle\Entity\Category, ~]
tags:
- { name: sonata.admin, manager_type: orm, group: Content, label: Category }
public: true
这将在屏幕截图中显示的菜单上显示一个 "Content" 选项卡,其中包含 2 个选项:'Blog post' 和 'Category'
由于菜单是通过遍历注册的管理员自动构建的,因此没有(据我所知)仅添加一个管理服务条目的简单解决方案。但这还很容易。您可以注册一个 MenuBuilderListener 并根据需要添加新项目...
在你的services.yml
app.menu_listener:
class: AppBundle\Listener\MenuBuilderListener
tags:
- { name: kernel.event_listener, event: sonata.admin.event.configure.menu.sidebar, method: addMenuItems }
在你的MenuBuilderListener中class
public function addMenuItems(ConfigureMenuEvent $event)
{
$event->getMenu()->addChild($event->getFactory()->createItem('Test entry', ['route' => 'custom_route']));
...
}
该事件在您的菜单构建后调用...您可以在之后更改现有菜单条目或仅添加新条目。请注意,管理服务通常会负责创建路由,如果您没有管理员,则必须自己构建路由。
是的,你可以这样做:
sonata_admin:
title: Supplier Portal
title_logo: bundles/supplierportalbackend/img/logo.png
show_mosaic_button: false
security:
handler: sonata.admin.security.handler.role
templates:
layout: SonataAdminBundle::layout.html.twig
search: SonataAdminBundle:Core:search.html.twig
search_result_block: SonataAdminBundle:Block:block_search_result.html.twig
base_list_field: SonataAdminBundle:CRUD:base_list_field.html.twig
dashboard:
blocks:
- { position: left, type: sonata.admin.block.admin_list }
# Customize user portal menu by setting links
groups:
sonata.admin.group.purchase_order_item.open:
on_top: true
label: Open Items
label_catalogue: messages
icon: '<i class="fa fa-square-o"></i>'
items:
- supplier_portal_backend.admin.purchase_open_order_item
sonata.admin.group.purchase_order_item.confirmed:
on_top: true
label: Confirmed Items
label_catalogue: messages
icon: '<i class="fa fa-check-square-o"></i>'
items:
- supplier_portal_backend.admin.purchase_confirmed_order_item
sonata.admin.group.purchase_order_item.shipped:
on_top: true
label: Shipped Items
label_catalogue: messages
icon: '<i class="fa fa-truck"></i>'
items:
- supplier_portal_backend.admin.purchase_shipped_order_item
sonata.admin.group.purchase_order_item.all:
on_top: true
label: All Items
label_catalogue: messages
icon: '<i class="fa fa-th-list"></i>'
items:
- supplier_portal_backend.admin.purchase_order_item
sonata.admin.group.administration:
on_top: true
label: Users
label_catalogue: messages
icon: '<i class="fa fa-users"></i>'
items:
- supplier_portal_backend.admin.user
roles: [ ROLE_SUPER_ADMIN ]
我找不到(理解)如何将项目和类别添加到左侧管理菜单。 没有详细的教程如何做到这一点。 我可以将项目添加到 sonata.admin.block.admin_list 但放在管理菜单旁边 enter image description here
您需要在路由中添加一条路线:
admin.blog_post:
class: db306\CoreBundle\Admin\BlogPostAdmin
arguments: [~, db306\CoreBundle\Entity\BlogPost, ~]
tags:
- { name: sonata.admin, manager_type: orm, group: Content, label: Blog post }
public: true
admin.category:
class: db306\CoreBundle\Admin\CategoryAdmin
arguments: [~, db306\CoreBundle\Entity\Category, ~]
tags:
- { name: sonata.admin, manager_type: orm, group: Content, label: Category }
public: true
这将在屏幕截图中显示的菜单上显示一个 "Content" 选项卡,其中包含 2 个选项:'Blog post' 和 'Category'
由于菜单是通过遍历注册的管理员自动构建的,因此没有(据我所知)仅添加一个管理服务条目的简单解决方案。但这还很容易。您可以注册一个 MenuBuilderListener 并根据需要添加新项目...
在你的services.yml
app.menu_listener:
class: AppBundle\Listener\MenuBuilderListener
tags:
- { name: kernel.event_listener, event: sonata.admin.event.configure.menu.sidebar, method: addMenuItems }
在你的MenuBuilderListener中class
public function addMenuItems(ConfigureMenuEvent $event)
{
$event->getMenu()->addChild($event->getFactory()->createItem('Test entry', ['route' => 'custom_route']));
...
}
该事件在您的菜单构建后调用...您可以在之后更改现有菜单条目或仅添加新条目。请注意,管理服务通常会负责创建路由,如果您没有管理员,则必须自己构建路由。
是的,你可以这样做:
sonata_admin:
title: Supplier Portal
title_logo: bundles/supplierportalbackend/img/logo.png
show_mosaic_button: false
security:
handler: sonata.admin.security.handler.role
templates:
layout: SonataAdminBundle::layout.html.twig
search: SonataAdminBundle:Core:search.html.twig
search_result_block: SonataAdminBundle:Block:block_search_result.html.twig
base_list_field: SonataAdminBundle:CRUD:base_list_field.html.twig
dashboard:
blocks:
- { position: left, type: sonata.admin.block.admin_list }
# Customize user portal menu by setting links
groups:
sonata.admin.group.purchase_order_item.open:
on_top: true
label: Open Items
label_catalogue: messages
icon: '<i class="fa fa-square-o"></i>'
items:
- supplier_portal_backend.admin.purchase_open_order_item
sonata.admin.group.purchase_order_item.confirmed:
on_top: true
label: Confirmed Items
label_catalogue: messages
icon: '<i class="fa fa-check-square-o"></i>'
items:
- supplier_portal_backend.admin.purchase_confirmed_order_item
sonata.admin.group.purchase_order_item.shipped:
on_top: true
label: Shipped Items
label_catalogue: messages
icon: '<i class="fa fa-truck"></i>'
items:
- supplier_portal_backend.admin.purchase_shipped_order_item
sonata.admin.group.purchase_order_item.all:
on_top: true
label: All Items
label_catalogue: messages
icon: '<i class="fa fa-th-list"></i>'
items:
- supplier_portal_backend.admin.purchase_order_item
sonata.admin.group.administration:
on_top: true
label: Users
label_catalogue: messages
icon: '<i class="fa fa-users"></i>'
items:
- supplier_portal_backend.admin.user
roles: [ ROLE_SUPER_ADMIN ]