blinks4451850
blinks4451850

Hello! Is it possible to reorder and group items in the backend menu? All i've found is this link https://octobercms.com/docs/plugin/extending#extending-backend-menu , but there are only methods to rename/delete items, not reorder/group items.

Thank you!

mjauvin
mjauvin

As far as I know, you cannot reorder/group menu items.

blinks4451850
blinks4451850

I've found a solution, it is not very elegant, but if client insists... In our Plugin.php we can re-activate existing menu items:

public function boot()
{
    \Event::listen('backend.menu.extendItems', function ($manager) {
        $manager->addMainMenuItems('October.Backend', [
            'dashboard' => [
                'order' => '1'
            ]
        ]);
        $manager->addMainMenuItems('October.Cms', [
            'cms' => [
                'order' => '2'
            ]
        ]);
        $manager->addMainMenuItems('October.Backend', [
            'media' => [
                'order' => '3'
            ]
        ]);
       $manager->addMainMenuItems('RainLab.Builder', [
            'builder' => [
                'order' => '4'
            ]
        ]);
    });
}

And we can do this for any plugin we create.

Last updated

mjauvin
mjauvin

neat! didn't know you could just add them back like this with an order key.

mjauvin
mjauvin

I found what I think is a cleaner/simpler way to order menu items:


Event::listen('backend.menu.extendItems', function ($manager) {
   $items = $manager->listMainMenuItems();
   $data = [
       'October.Backend.Dashboard' => 1,
       'October.Cms.cms' => 2,
       'October.Backend.Media' => 3,
       'RainLab.Builder.Builder' => 4,
   ];
   foreach ( as $name => $order) {
       if ($item = array_get($items, strtoupper($name), false)) {
           $item->order = $order;
       }
   }
});
blinks4451850
blinks4451850

Nice! For ordering your solution is really the best. For ordering, renaming, etc, my ugly solution works too)

1-6 of 6