Hide Settings menu when no sub pages to display (#3172)
Remove the Settings main menu item if there are no submenus to display. Fixes https://github.com/octobercms/october/issues/2175
This commit is contained in:
parent
ac2e5937f0
commit
aee81081df
|
|
@ -313,14 +313,18 @@ class NavigationManager
|
||||||
* Returns a list of side menu items for the currently active main menu item.
|
* Returns a list of side menu items for the currently active main menu item.
|
||||||
* The currently active main menu item is set with the setContext methods.
|
* The currently active main menu item is set with the setContext methods.
|
||||||
*/
|
*/
|
||||||
public function listSideMenuItems()
|
public function listSideMenuItems($owner = null, $code = null)
|
||||||
{
|
{
|
||||||
$activeItem = null;
|
$activeItem = null;
|
||||||
|
|
||||||
foreach ($this->listMainMenuItems() as $item) {
|
if (!is_null($owner) && !is_null($code)) {
|
||||||
if ($this->isMainMenuItemActive($item)) {
|
$activeItem = @$this->items[$this->makeItemKey($owner, $code)];
|
||||||
$activeItem = $item;
|
} else {
|
||||||
break;
|
foreach ($this->listMainMenuItems() as $item) {
|
||||||
|
if ($this->isMainMenuItemActive($item)) {
|
||||||
|
$activeItem = $item;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -354,6 +354,18 @@ class ServiceProvider extends ModuleServiceProvider
|
||||||
'system',
|
'system',
|
||||||
'~/modules/system/partials/_system_sidebar.htm'
|
'~/modules/system/partials/_system_sidebar.htm'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Remove the October.System.system main menu item if there is no subpages to display
|
||||||
|
*/
|
||||||
|
Event::listen('backend.menu.extendItems', function ($manager) {
|
||||||
|
$systemSettingItems = SettingsManager::instance()->listItems('system');
|
||||||
|
$systemMenuItems = $manager->listSideMenuItems('October.System', 'system');
|
||||||
|
|
||||||
|
if (empty($systemSettingItems) && empty($systemMenuItems)) {
|
||||||
|
$manager->removeMainMenuItem('October.System', 'system');
|
||||||
|
}
|
||||||
|
}, -9999);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue