muuk
muuk

Reputation: 932

OctoberCMS Sidebar not rendering

I have been trying to get familiar with octobercms, but I've come across an issue I can't seem to resolve. I have a backend controller setup with views etc. Everything works, except that the sidebar isn't loading. Also the tab isn't getting the active state.

http://gyazo.com/25e019c1db34d5807c05ebb4b3277ac7

It should look something like this:

http://gyazo.com/c71a1e1dec7c1e6b81136b313b32da47

Here is a gist with my code: https://gist.github.com/muuknl/fedb8434219c7dbe5d04

If I forgot to give certain information, please let me know and thanks in advance for the help.

Upvotes: 1

Views: 1376

Answers (1)

Anand Patel
Anand Patel

Reputation: 3943

here is simple solution

in controller you need to write

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

refer this https://octobercms.com/docs/backend/controllers-views-ajax#navigation-context

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

you need to write same thing what you have written in plugin.php in registerNavigation() function

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']
                    ]
                ]

            ]
        ];
    }

Upvotes: 6

Related Questions