gpt4 book ai didi

php - Symfony 2 - 顶部菜单未出现在 Sonata admin 中

转载 作者:可可西里 更新时间:2023-10-31 22:44:02 24 4
gpt4 key购买 nike

顶级菜单未出现在我的 Sonata 管理员中。菜单仅出现在仪表板中。

我按照以下教程创建了博客功能的后端: http://sonata-project.org/bundles/doctrine-orm-admin/master/doc/tutorial/creating_your_first_admin_class/introduction.html

我也试过像下面这样配置 app/config/config.yml

sonata_admin:
dashboard:
groups:
Blog:

但没有得到预期的结果(即顶部菜单)。

最佳答案

从 2.2 版开始,这是一个安全问题。配置完成后 as the docs says , 菜单将正常显示。

更新:此外,根据the 2012-06-05 entry on the changelog,用户必须具有角色ROLE_SONATA_ADMIN .

如果你想在不这样做的情况下测试它,你可以set a new layout template基于此文件:https://github.com/sonata-project/SonataAdminBundle/blob/master/Resources/views/standard_layout.html.twig , 但在 sonata_top_bar_nav block 中注释与菜单绘制相关的一些行,如下所示:

{% block sonata_top_bar_nav %}
{#% if app.security.token and is_granted('ROLE_SONATA_ADMIN') %#}
{% for group in admin_pool.dashboardgroups %}
{% set display = (group.roles is empty or is_granted('ROLE_SUPER_ADMIN') ) %}
{% for role in group.roles if not display %}
{% set display = is_granted(role) %}
{% endfor %}

{# Do not display the group label if no item in group is available #}
{% set item_count = 0 %}
{% if display %}
{% for admin in group.items if item_count == 0 %}
{% if admin.hasroute('list') and admin.isGranted('LIST') %}
{% set item_count = item_count+1 %}
{% endif %}
{% endfor %}
{% endif %}

{#% if display and (item_count > 0) %#}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ group.label|trans({}, group.label_catalogue) }} <span class="caret"></span></a>
<ul class="dropdown-menu">
{% for admin in group.items %}
{#% if admin.hasroute('list') and admin.isGranted('LIST') %#}
<li><a href="{{ admin.generateUrl('list')}}">{{ admin.label|trans({}, admin.translationdomain) }}</a></li>
{#% endif %#}
{% endfor %}
</ul>
</li>
{# % endif %#}
{% endfor %}
{#% endif %#}
{% endblock %}

关于php - Symfony 2 - 顶部菜单未出现在 Sonata admin 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19267356/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com