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

报告相同问题?

悬赏问题

  • ¥18 深度学习tensorflow1,ssdv1,coco数据集训练一个模型
  • ¥100 关于注册表摄像头和麦克风的问题
  • ¥30 代码本地运行正常,但是TOMCAT部署时闪退
  • ¥15 关于#python#的问题
  • ¥15 主机可以ping通路由器但是连不上网怎么办
  • ¥15 数据库一张以时间排好序的表中,找出多次相邻的那些行
  • ¥50 关于DynamoRIO处理多线程程序时候的问题
  • ¥15 kubeadm部署k8s出错
  • ¥15 Abaqus打不开cae文件怎么办?
  • ¥15 小程序准备上线,软件开发公司需要提供哪些资料给甲方