octobercms-側邊攔外掛

jcc123發表於2020-09-26

octobercms 側邊攔外掛,符合國內使用習慣

octobercms 後臺不符合國內審美,導航欄在頂部。該外掛可以實現左邊導航欄,下拉選擇。

1

安裝

git clone https://github.com/octobercms-plugin/oc-plugin-sidenav.git plugins/jcc/sidenav

如何使用

1 在Plugin.php的regiser,註冊頂部導航模組

    public function register()
    {

        BackendMenu::registerCallback(function ($manager) {
            $manager->registerMenuItems('October.System', [
                'bar' => [
                    'label'       => '模組1',
                    'icon'        => 'icon-cog',
                    'iconSvg'     => 'modules/system/assets/images/cog-icon.svg',
                    'url'         => Backend::url('october/hello/worlds'),
                    'permissions' => [],
                    'order'       => 1000
                ]
            ]);
        });
        BackendMenu::registerContextSidenavPartial(
            'October.System',
            'bar',
            '~/plugins/jcc/sidenav/partials/_system_sidebar.htm'
        );

        BackendMenu::registerCallback(function ($manager) {
            $manager->registerMenuItems('October.System', [
                'bar1' => [
                    'label'       => '模組2',
                    'icon'        => 'icon-cog',
                    'iconSvg'     => 'modules/system/assets/images/cog-icon.svg',
                    'url'         => Backend::url('october/hello/worlds'),
                    'permissions' => [],
                    'order'       => 1000
                ]
            ]);
        });
        BackendMenu::registerContextSidenavPartial(
            'October.System',
            'bar1',
            '~/plugins/jcc/sidenav/partials/_system_sidebar.htm'
        );
}

2 註冊左邊導航

public function registerSideNavSettings()
    {
        return [
            'hello' => [
                'label' => '導航1',
                'description' => 'rainlab.blog::lang.blog.settings_description',
                'category' => '分類1',
                'icon' => 'icon-pencil',
                'url'         => Backend::url('october/hello/worlds'),
                'order' => 500,
                'context'=>'bar',//對應模組1的識別符號
                'keywords' => 'blog post category',
                'permissions' => ['rainlab.blog.manage_settings']
            ],
            'hello1' => [
                'label' => '導航2',
                'description' => 'rainlab.blog::lang.blog.settings_description',
                'category' => '分類2',
                'icon' => 'icon-pencil',
                'url'         => Backend::url('october/hello/worlds'),
                'order' => 500,
                'context'=>'bar',
                'keywords' => 'blog post category',
                'permissions' => ['rainlab.blog.manage_settings']
            ],
            'hello2' => [
                'label' => '導航3',
                'description' => 'rainlab.blog::lang.blog.settings_description',
                'category' => '分類3',
                'icon' => 'icon-pencil',
                'url'         => Backend::url('october/hello/worlds'),
                'order' => 500,
                'context'=>'bar',
                'keywords' => 'blog post category',
                'permissions' => ['rainlab.blog.manage_settings']
            ],
        ];
    }

3 在控制器中使用側邊攔導航


    public function __construct()
    {
        parent::__construct();
        $this->vars['result'] = 'Hello world!';

        \BackendMenu::setContext('October.System', 'bar');//使用頂部模組1導航欄
        \Jcc\Sidenav\Classes\SideNavManager::setContext('October.Hello', 'hello');//選中側邊攔

    }
本作品採用《CC 協議》,轉載必須註明作者和本文連結
NOT IS BECAUSE I WANT TO WRITE, BUT I WANT TO INCREASE, SO I GO TO WRITE~~

相關文章