1

我一直在尝试熟悉 octobercms,但遇到了一个似乎无法解决的问题。我有一个带有视图等的后端控制器设置。一切正常,除了侧边栏没有加载。该选项卡也没有处于活动状态。

http://gyazo.com/25e019c1db34d5807c05ebb4b3277ac7

它应该看起来像这样:

http://gyazo.com/c71a1e1dec7c1e6b81136b313b32da47

这是我的代码的要点:https ://gist.github.com/muuknl/fedb8434219c7dbe5d04

如果我忘记提供某些信息,请让我知道并提前感谢您的帮助。

4

1 回答 1

6

这是简单的解决方案

在控制器中你需要写

BackendMenu::setContext('Archetypics.Team', 'website', 'team');

参考这个https://octobercms.com/docs/backend/controllers-views-ajax#navigation-context

BackendMenu::setContext('Author.Plugin name', 'Menu code', 'Sub menu code');

你需要写你plugin.php在 registerNavigation() 函数中写的东西

public function registerNavigation()
    {
        return [
            // menu code 
            'website' => [
                'label'       => 'Website',
                'url'         => Backend::url('muukrls/archetypics/team'),
                'icon'        => 'icon-pencil',
                'permissions' => ['archetypics.*'],
                'order'       => 500,

                'sideMenu' => [
                    'home' => [
                        'label'       => 'Homepage',
                        'icon'        => 'icon-copy',
                        'url'         => Backend::url('muukrls/archetypics/home'),
                        'permissions' => ['archetypics.home_access'],
                    ],
                    'about' => [
                        'label'       => 'About Page',
                        'icon'        => 'icon-list-ul',
                        'url'         => Backend::url('muukrls/archetypics/about'),
                        'permissions' => ['archetypics.about_access'],
                    ],

                    // sub menu code
                    'team' => [
                        'label'       => 'Team Members',
                        'icon'        => 'icon-users',
                        'url'         => Backend::url('muukrls/archetypics/team'),
                        'permissions' => ['archetypics.team_access']
                    ]
                ]

            ]
        ];
    }
于 2014-12-02T17:02:42.397 回答