duannian7116 2017-04-21 10:11
浏览 41
已采纳

OctoberCMS registerNavigation当前活动子菜单链接的错误状态

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.

  • 写回答

1条回答 默认 最新

  • doukang7486 2017-04-21 10:20
    关注

    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');
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?