backend.menu.extendItems in Plugin.php breaks the menu

Hello,

I tried my plugin on version 3.1.19 (works fine on version 2.x). In Plugin.php, I have a boot method, with an Event::listen to change menu label. I noticed that in version 3, it breaks the modified menu (icons are gone, submenus are not showing, no URL, etc…).

Any idea why ? I reviewed doc (Extension Methodology - October CMS - 3.x) but no change with 2.x.

Here’s an example with a test Plugin trying to change the name of Builder Plugin menu.

    public function boot()
    {
        Event::listen('backend.menu.extendItems', function($manager) {
            $manager->addMainMenuItems('rainlab.builder', [
                'builder' => [
                    'label' => 'My own Builder'
                ]
            ]);
        });
    }

Thanks for your help !

Jan

Use getMainMenuItem instead:

$navigationManager->getMainMenuItem('RainLab.Builder', 'builder')->config['label'] = 'Your own Builder';
1 Like

Thanks a lot for this interesting advice, @Eoler ! This worked fine for the MainMenu.

I still have the same issue with the SideMenu. Icons, URL’s and other behaviors just disapear.

I use this code.

$manager->addSideMenuItems('RainLab.Builder', 'builder', [
    'fake-example' => [
        'label' => e(Settings::get('fake_builder_text', 'Hello buildy')),
        ]
    ]);

I haven’t found the getSideMenuItem equivalent. Any idea ?

Thanks a lot for your help,
have a nice day.

Don’t know the equivalent, but try to trace_log main menu item config array and manipulate it.

1 Like

Thanks,

Here’s my code to change some attributes on the SideMenus (for example, a label) :

$manager->getMainMenuItem('RainLab.Builder', 'builder')
    ->config['sideMenu']['fake_example']
        ->config['label'] = 'Funny side menu';

Greetings

1 Like