Search code examples
phpoctobercmsoctobercms-backendoctobercms-plugins

OctoberCMS registerNavigation wrong status of current active submenu link


I have been using OctoberCMS(Builder Plugin) to create different plugins, which works well.

I have a plugin called as Partners and in Plugin.php file code , I have below code.

Plugin.php code

public function registerNavigation()
    {
        return [
            'modules' => [
                'label'       => 'Modules',
                'url'         => Backend::url('technobrave/partners/partners'),
                'icon'        => 'icon-bars',
                'permissions' => ['Technobrave.Partner.*'],

                'sideMenu'    => [
                    'partner' => [
                            'label' => 'Partners',
                            'icon'        => 'icon-thumbs-up',
                            'url'         => Backend::url('technobrave/partners/partners'),
                            'permissions' => ['Technobrave.Partner.*']

                    ],
                    'team' => [
                            'label' => 'Team',
                            'icon'        => 'icon-group',
                            'url'         => Backend::url('technobrave/team/team'),
                            'permissions' => ['Technobrave.Team.*']
                    ]
                ]
            ]
        ];
    }

And here below is my Partners.php controller file code

Partners.php controller code

public function __construct()
    {
        parent::__construct();             
        BackendMenu::setContext('Technobrave.Partners', 'modules', 'team');
    }

Everything works fine apart from my current active class, even if I am on the Partners page, it is still selecting "Team" as current menu link. Below is the screen shot with browser URL for better understanding.

enter image description here

As you can see above, I am on Partners page still its showing current active URL as Team page. Can someone help me how to handle this ?

Thanks

PS: Added PHP tag if someone tag just for the shake of help I need if someone knows and had ever come across using this CMS.


Solution

  • You need to set the menu context for each controller. For the Partners.php use this:

    public function __construct()
    {
        parent::__construct();             
        BackendMenu::setContext('Technobrave.Partners', 'modules', 'partner');
    }
    

    And for the Team.php use this:

    public function __construct()
    {
        parent::__construct();             
        BackendMenu::setContext('Technobrave.Partners', 'modules', 'team');
    }