微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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 %}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐