显示/隐藏某些菜单取决于Sonata管理员角色 [英] show/hide some menus depend on the Sonata admin ROLE
问题描述
我正在使用Symfony2开发一个Web项目,并且我将Sonata Admin用于管理面板,一切正常,但是我想做的是,在sonata Admin的仪表板菜单上,我需要显示一些隐藏内容菜单取决于管理员角色,所以有人以前做过此事,还是知道如何做? 我尝试使用角色的配置,但是当我与ROLE_SONATA_ADMIN的ROlE差异连接时,顶部菜单不显示,
I'm working on a web project using Symfony2 , and i used Sonata Admin for the admin Panel , every thing works fine but what i want to do is ,on the dashboard menus of sonata Admin , i need to show hide some menus depend on the admin ROLE , so did any one do this before or know how to do it ? i tryed to use the config of the roles but when i'm connecting with a ROlE diffrent of ROLE_SONATA_ADMIN the top menu dont show up ,
- { path: ^/admin, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN,ROLE_ADMIN_NEWS] }
谢谢
推荐答案
我找到了解决这个问题的方法,我只需要在config.yml上定义组即可
i found the solution for this i need just to define the groups on the config.yml Like this
dashboard:
groups:
Content:
label: Content
items:
- sonata.admin.pages
- sonata.admin.menus
roles: [ ROLE_ADMIN_CONTENT, ROLE_SUPER_ADMIN ]
这篇关于显示/隐藏某些菜单取决于Sonata管理员角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!