我无法找到(了解)如何向左侧管理菜单添加项目和导管。 没有详细的教程如何做到这一点。 我可以将项目添加到sonata.admin.block.admin_list,但是除了管理员菜单 enter image description here
答案 0 :(得分:1)
由于菜单是通过遍历已注册的管理员自动构建的,因此通过仅添加管理服务条目,没有(对我而言)简单的解决方案。但它很容易。您可以注册一个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类
中public function addMenuItems(ConfigureMenuEvent $event)
{
$event->getMenu()->addChild($event->getFactory()->createItem('Test entry', ['route' => 'custom_route']));
...
}
在您的菜单构建之后调用该事件...您可以在之后更改现有菜单条目或仅添加新条目。请注意,管理服务通常会负责创建路由,如果您没有管理员,则必须自己构建路由。
答案 1 :(得分:1)
是的,你可以这样做:
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 ]
答案 2 :(得分:0)
您需要为路线添加路线:
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
这将显示&#34;内容&#34;屏幕截图上显示的菜单上有两个选项:&#39; Blog post&#39;和&#39;类别&#39;