Najbo
October 31, 2022, 12:46pm
#1
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
Eoler
October 31, 2022, 6:56pm
#2
Use getMainMenuItem instead:
$navigationManager->getMainMenuItem('RainLab.Builder', 'builder')->config['label'] = 'Your own Builder';
1 Like
Najbo
November 1, 2022, 6:47am
#3
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.
Eoler
November 2, 2022, 7:35am
#4
Don’t know the equivalent, but try to trace_log
main menu item config
array and manipulate it.
2 Likes
Najbo
November 2, 2022, 5:22pm
#5
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
2 Likes