Nested menu items at SonataAdminBundle sidebar
NickName:ReynierPM Ask DateTime:2015-06-11T10:18:03

Nested menu items at SonataAdminBundle sidebar

I would like to nested menu items like a tree. I have this configuration at the moment:

dashboard:
    groups:
        company:
            icon: <i class="fa fa-lg fa-fw fa fa-cogs"></i>
            label: Company
            items:
                - sonata.admin.company
                - sonata.admin.brand
                - sonata.admin.media
                - sonata.admin.message
        territory:
            icon: <i class="fa fa-lg fa-fw fa fa-cogs"></i>
            label: Territory
            items:
                - sonata.admin.territory
                - sonata.admin.target
        reps:
            icon: <i class="fa fa-lg fa-fw fa fa-cogs"></i>
            label: Representative
            items:
                - sonata.admin.representative
                - sonata.admin.email
                - sonata.admin.targetbrand
                - sonata.admin.territorybrand

And I would like have something like:

dashboard:
    groups:
        company:
            icon: <i class="fa fa-lg fa-fw fa fa-cogs"></i>
            label: Company
            label_catalogue: PDOneBundle
            items:
                - sonata.admin.company
                    - sonata.admin.brand
                        - sonata.admin.media
                        - sonata.admin.message
        territory:
            icon: <i class="fa fa-lg fa-fw fa fa-cogs"></i>
            label: Territory
            label_catalogue: PDOneBundle
            items:
                - sonata.admin.territory
                     - sonata.admin.target
        reps:
            icon: <i class="fa fa-lg fa-fw fa fa-cogs"></i>
            label: Representative
            label_catalogue: PDOneBundle
            items:
                - sonata.admin.representative
                    - sonata.admin.email

How I can do that? It's possible?

UPDATE

Based on the docs by SonataAdminBundle and recommended by @hugo-briand I made some changes by extending the menu so I have created a file under PDI\PDOneBundle\EventListener\MenuBuilderListener.php and looks like this:

namespace PDI\PDOneBundle\EventListener;
use Sonata\AdminBundle\Event\ConfigureMenuEvent;

class MenuBuilderListener
{
    public function createMainMenu(ConfigureMenuEvent $event)
    {
        $menu = $event->getMenu();

            $menu
                ->addChild('Dashboard', array('uri' => '/'))
                ->setAttribute('icon', 'fa fa-home');

            $menu
                ->addChild('Company', array())
                ->setAttribute('icon', 'fa fa-inbox')
                ->addChild('Company', array(
                   'route' => 'admin_pdi_pdone_company_list',
                ))
                ->setAttribute('icon', 'fa fa-inbox')
                ->getParent()
                ->addChild('Brand', array(
                    'route' => 'admin_pdi_pdone_brand_list',
                ))
                ->setAttribute('icon', 'fa fa-inbox')
                ->addChild('Media', array(
                    'route' => 'admin_pdi_pdone_media_list',
                ))
                ->setAttribute('icon', 'fa fa-inbox')
                ->getParent();
    }
}

Then I registered the listener at PDI\PDOneBundle\Resources\config\services.yml as follow:

services:
    app.menu_listener:
        class: PDI\PDOneBundle\EventListener\MenuBuilderListener
        tags:
            - { name: kernel.event_listener, event: sonata.admin.event.configure.menu.sidebar, method: createMainMenu }

But is not working since the same default menu still showing. Any advice?

Copyright Notice:Content Author:「ReynierPM」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/30770470/nested-menu-items-at-sonataadminbundle-sidebar

More about “Nested menu items at SonataAdminBundle sidebar” related questions

Nested menu items at SonataAdminBundle sidebar

I would like to nested menu items like a tree. I have this configuration at the moment: dashboard: groups: company: icon: &lt;i class="fa fa-lg fa-fw fa fa-cogs"&gt;&lt;/i&...

Show Detail

How to assign app.user data to SonataAdminBundle SideMenu

I'm trying to dynamically assign menu items in the SonataAdminBundle SideBar menu based on data from the logged in user such as app.user.id Do you have any idea how to do that ? david

Show Detail

Nested sidebar menu with material ui and Reactjs

I am trying to develop a sidebar menu using material ui. I am able to make it for simple list. In my project I have a requirement of nested sidebar menu which I am not able to achieve. If I am tryi...

Show Detail

sidebar does not scroll to the bottom when unfolding menu items

I'm using a layout for a web app where I have a sidebar menu on the left. The menu is made of several items which can unfold to show the menu sub items. My problem is : when several items are unfol...

Show Detail

can anyone help me to create nested sidebar menu with chakra ui

Need to create side bar menu with chakra ui Creating nested sidebar menu with chakra ui.Need to create nested sidebar menu with chakra ui .Thnks in advance

Show Detail

Image button click twice to show sidebar Menu

I have a sidebar menu that shows on a single click on my image button when the menu contents are HTML and items. I changed the menu contents to be from a database menu nested in a usercontrol, the

Show Detail

SonataAdminBundle custom group icon

I'm using SonataAdminBundle to generate a CRUD for my Page entity. With the yaml file bellow the menu is displayed in the sidebar. I would like to change the group default icon which is "fa fa-f...

Show Detail

How to display top and side menu in SonataAdminBundle?

There are no documents talk about that. Please help me. Thank you

Show Detail

Sidebar Nested Dropdown Menu Reactjs

I tried to build a nested dropdown menu from scratch on a sidebar. The issue is when I open a nested menu it opens all nested menu that is in the sidebar at the same time, how should I manage to only

Show Detail

Bootstrap sidebar navigation remember expanded items

I have a bootstrap sidebar with nested collapsible links. Each link of course re-loads the page when clicked which causes the menu to collapse. I was wondering if there was a way to keep the sidebar

Show Detail