diff --git a/Plugin.php b/Plugin.php index cdaf208..2eeab7d 100644 --- a/Plugin.php +++ b/Plugin.php @@ -7,6 +7,7 @@ use Cms\Classes\Controller as CmsController; use Cms\Classes\Page as CmsPage; use System\Classes\PluginBase; use System\Traits\AssetMaker; +use System\Traits\EventEmitter; /** * Menu Plugin Information File @@ -16,6 +17,7 @@ class Plugin extends PluginBase const ICON = 'icon-sliders'; use AssetMaker; + use EventEmitter; /** * @var CmsController diff --git a/classes/Extend.php b/classes/Extend.php index a67b9a4..e17a727 100644 --- a/classes/Extend.php +++ b/classes/Extend.php @@ -2,6 +2,7 @@ namespace Wms\Menu\Classes; +use Backend\Classes\SideMenuItem; use Backend\Models\User; use System\Classes\PluginManager; @@ -51,13 +52,20 @@ class Extend if ($page) { self::$navigation['sideMenu'][$name] = [ 'label' => isset($page['label']) ? $page['label'] : 'wms.menu::lang.no-name', - 'group' => $group, 'url' => isset($page['url']) ? $page['url'] : '#', 'icon' => isset($page['icon']) ? $page['icon'] : 'icon-leaf', - 'icon_base64' => isset($page['icon_base64']) ? $page['icon_base64'] : '', - 'icon_base64_minimized' => isset($page['icon_base64_minimized']) ? $page['icon_base64_minimized'] : '', + 'attributes' => [ + 'group' => $group, + 'icon_base64' => isset($page['icon_base64']) ? $page['icon_base64'] : '', + 'icon_base64_minimized' => isset($page['icon_base64_minimized']) ? $page['icon_base64_minimized'] : '', + 'keywords' => isset($page['keywords']) ? $page['keywords'] : '', + 'description' => isset($page['description']) ? $page['description'] : '' + ], 'permissions' => isset($page['permissions']) ? $page['permissions'] : ['wms.*'], ]; + /** + * @see SideMenuItem::createFromArray() + */ } } } diff --git a/partials/menu/main/_system_sidebar_menu.phtml b/partials/menu/main/_system_sidebar_menu.phtml index 5fa7038..8f42913 100644 --- a/partials/menu/main/_system_sidebar_menu.phtml +++ b/partials/menu/main/_system_sidebar_menu.phtml @@ -5,18 +5,11 @@ ? $_COOKIE['sidenav_treegroupStatus'] : null ); + $categories = []; + foreach ($sideMenuItems as $sideItemCode => $item) { - if(!property_exists($item, 'group')) { - $item->group = 'default'; - } - if(!property_exists($item, 'keywords')) { - $item->keywords = ''; - } - if(!property_exists($item, 'description')) { - $item->description = ''; - } - $categories[$item->group][$sideItemCode] = $item; + $categories[$item->attributes['group']][$sideItemCode] = $item; } ?>