魔众轻量论坛系统后台导航菜单注册

魔众轻量论坛系统 / 文档中心
文档中心
开发教程
安装常见问题

Core/ModuleServiceProvider.php 中配置,通过如下方式注册菜单:

AdminMenu::register(function () {
    return [
        [
            // 菜单标题
            'title' => '一级菜单',
            // 导航图标,可从以下图标 class 值,如 list 或 fa fa-search
            // → 基础图标 https://modstart.com/ui/manual/icon
            // → Font Awesome 图标 https://modstart.com/ui/manual/icon_fa
            'icon' => 'tools',
            // 菜单排序
            'sort' => 150,
            // 菜单子菜单
            'children' => [
                [
                    'title' => '二级菜单',
                    // 菜单链接 Controller 和 Action
                    'url' => '\Module\Xxx\Admin\Controller\XxxController@index',
                ]
            ]
        ],
        [
            'title' => '一级菜单',
            'icon' => 'tools',
            'sort' => 150,
            'children' => [
                [
                    'title' => '二级菜单',
                    'children' => [
                        [
                            'title' => '三级菜单',
                            'url' => '\Module\Xxx\Admin\Controller\XxxController@index',
                        ],
                        [
                            'title' => '三级菜单',
                            'url' => '\Module\Xxx\Admin\Controller\XxxController@index',
                        ]
                    ],
                ]
            ]
        ],
    ];
});

ModStart系统按照如下相同的规则进行菜单合并:

  • 一级菜单(title+icon+sort)
  • 二级菜单(title)

如需要隐藏某一个菜单不显示在菜单栏但出现在权限管理中,只需要给菜单项增加参数,如下

// ...
[
  'title' => '二级菜单',
  'url' => '\Module\Xxx\Admin\Controller\XxxController@index',
  // 增加该参数不会显示在菜单栏
  'hide' => true,
]
// ...
QQ
微信
公众号