Extend admin sidebar
To extend the administration sidebar with custom sidebar links to e.g. custom pages, you can easily integrate the
public function administrationMenu(Menu $sidebarMenu)in the base class of your module. You will get an instance of App\Framework\Core\Menu\Menu and should return the menu. In the meantime, you can add custom menu items.
You are allowed to add menu items on the first level, but you can also create sub-items of already existing sidebar items. This can look as following:
class dashservVps implements ModuleBase {
public function activate(ModuleLifecycleContext $lifecycleContext) {}
public function deactivate(ModuleLifecycleContext $lifecycleContext) {}
public function install(ModuleLifecycleContext $lifecycleContext) {}
public function uninstall(ModuleLifecycleContext $lifecycleContext) {}
// the magic happens in this method!
public function administrationMenu(Menu $sidebarMenu): Menu {
// menu item on the first level
$sidebarMenu->addChild(new MenuItem(
"dsahservvps",
"dashserv VPS",
route('dashserv-vps.index'),
"boxes"
));
// menu item on the second level (child)
$sidebarMenu->getChild('hosting')->addChild(new MenuItem(
"dashservvps-with-parent",
"dashserv VPS child",
route('dashserv-vps.index'),
));
return $sidebarMenu;
}
}The result will look like this:
Was this helpful?