php – Symfony 2 – 顶级菜单没有出现在Sonata管理员中

顶级菜单没有出现在我的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 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 %}

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...