Symfony 2 - top menu not showing in Sonata admin

The top menu does not appear in my Sonata admin. Menus are displayed only on the toolbar.

I completed the following tutorial and created a backend for the blog function: http://sonata-project.org/bundles/doctrine-orm-admin/master/doc/tutorial/creating_your_first_admin_class/introduction.html

I also tried setting app / config / config.yml as shown below

sonata_admin:
    dashboard:
        groups:
            Blog:

But the expected result (i.e. the top menu) was not received.

+4
source share
3 answers

2.2, . , , .

UPDATE: , ROLE_SONATA_ADMIN, 2012-06-05 .

, : 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 %}
+3

SONATA_ROLE_ADMIN

security.yml ROLE_ADMIN,

security:
    ...
    role_hierarchy:
        ...
        ROLE_ADMIN:       [ROLE_USER, ROLE_SONATA_ADMIN]
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
        ...
+2

yml config.yml.

:

imports:
    - { resource: @yourBundle/Resources/config/admin.yml }

admin.yml :

# website/yourBundle/Resources/config/admin.yml
services:
    sonata.admin.your:
        class: website\yourBundle\Admin\yourAdmin
        tags:
            - { name: sonata.admin, manager_type: orm, group: "Content", label: "Contact Management" }
        arguments:
            - ~
            - website\yourBundle\Entity\your
            - ~
        calls:
            - [ setTranslationDomain, [yourBundle]]
+1
source

All Articles