Sidebar: apply / modify different item grouping other than under 'Content' and 'Workshop'



  • Hi, I'd like to know where can I modify the grouping of the elements of the sidebar, meaning the elements under the 'Content' and 'Workshop' labels.


  • Global Moderator

    @zedee

    You would just add items under same title/translation and they would appear unified, also there's weight method to control weight :D

    For example in SidebarExtender.php

    $menu->group(trans('Store'), function (Group $group) {
    	$group->item(trans('location::module.sidebar.title'), function (Item $item) {
    	    $item->icon('fa fa-globe');
    	    $item->weight(5);
    	    $item->item(trans('location::countries.title.countries'), function (Item $item) {
    	        $item->icon('fa fa-globe');
    	        $item->weight(1);
    	        $item->append('admin.location.country.create');
    	        $item->route('admin.location.country.index');
    	        $item->authorize(
    	            $this->auth->hasAccess('location.countries.index')
    	        );
    	    });
    	    $item->item(trans('location::cities.title.cities'), function (Item $item) {
    	        $item->icon('fa fa-location-arrow');
    	        $item->weight(2);
    	        $item->append('admin.location.city.create');
    	        $item->route('admin.location.city.index');
    	        $item->authorize(
    	            $this->auth->hasAccess('location.cities.index')
    	        );
    	    });
    	    $item->item(trans('location::currencies.title.currencies'), function (Item $item) {
    	        $item->icon('fa fa-money');
    	        $item->weight(3);
    	        $item->append('admin.location.currency.create');
    	        $item->route('admin.location.currency.index');
    	        $item->authorize(
    	            $this->auth->hasAccess('location.currencies.index')
    	        );
    	    });
    	});
    }
    

    It would create new delimer/category in sidebar with name of Store or translation of Store, place it with weight of 5(that would be right under Dashboard).



  • Oh, right. Just found the way to do it while looking into the code.

    I solved this way (pretty similar):

    $menu->group(trans('broadcastmedia::broadcastmedia.sidebar.broadcast group'), function (Group $group) {
        $group->weight(5);
        
        $group->item(trans('broadcastmedia::broadcastmedia.title.broadcastmedia'), function (Item $item) {
            $item->icon('fa fa-television');
            $item->weight(1);
            $item->append('admin.broadcastmedia.broadcastmedia.create');
            $item->route('admin.broadcastmedia.broadcastmedia.index');
            $item->authorize(
                $this->auth->hasAccess('broadcastmedia.broadcastmedia.index')
                );
            });
    });
    

    But as far as I see, the Content and Workshop groups depend on the core modules...


  • Global Moderator

    @zedee What do you mean? You want to re-arrange things in Content and Workshop? Like remove/replace/add something?
    Well based on module load order you could probably rewrite entries.



  • @armababy

    Yep. The thing is that in the CMS I'm developing, none of this classification applies, as I'm developing whole independent modules, but now I've found that if the options are not present because of the user permissions', those labels don't appear, so it's fine!

    EDIT: Well, actually yes, I'd like another name instead of Content (Media module is 'trapped' inside that classification), and unless I unignore the Media Module, I cannot change the sidebar's classification. (And oh my... I cannot hide the Workshop group, even if I have no elements/modules to show to the user)


  • Global Moderator

    @zedee

    As it stands, you wold need module that's last by alphabet to re-arrange properly since Sidebar seems to be loading in that order.

    If you make something like zzsidebar_extender with only provider and sidebarextender you could remove/re-arrange groups/items.


Log in to reply