This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

sacwebdeveloper
sacwebdeveloper

In short, the BackendMenu sideMenu is not displaying and main menu is not turning active for my plugin.

I'm sure this has something to do with BackendMenu::setContext(), but I have been comparing my code to the RainLab.User and RainLab.Blog plugins and I do not see what is missing.

mycompany/myplugin/Plugin.php

<?php namespace MyCompany\MyPlugin;

use Backend;
use System\Classes\PluginBase;
class Plugin extends PluginBase
{
    public function pluginDetails()
    {
        return [
            'name'        => 'My Plugin',
            'description' => 'A really cool plugin.',
            'author'      => 'MyCompany',
            'icon'        => 'icon-leaf'
        ];
    }
    public function registerNavigation()
    {
        return [
            'myplugin' => [
                'label'         => 'My Plugin',
                'url'           => Backend::url('mycompany/myplugin/mycontroller'),
                'icon'          => 'icon-envelope',

                'sideMenu' => [
                    'mycontroller'       => [
                        'label'         => 'My Controller',
                        'url'           => Backend::url('mycompany/myplugin/mycontroller'),
                        'icon'          => 'icon-envelope',
                    ],
                ]
            ]
        ];
    }
}

mycompany/myplugin/controllers/MyController.php

<?php namespace MyCompany\MyPlugin\Controllers;

use BackendMenu;
use Backend\Classes\Controller;

class MyController extends Controller {

    public $implement = [
        'Backend.Behaviors.FormController',
        'Backend.Behaviors.ListController'
    ];

    public $pageTitle = "My Controller";

    public $bodyClass = 'compact-container';

    public $listConfig = 'list_config.yaml';
    public $formConfig = 'form_config.yaml';

    public function __construct()
    {
        parent::__construct();

        BackendMenu::setContext('MyCompany.MyPlugin', 'myplugin', 'mycontroller');
    }
}

I've registered the navigation and set the BackendMenu context as prescribed to others. Any ideas?

Last updated

sacwebdeveloper
sacwebdeveloper

Solved! Haha! A missing character in public function __construct. I think I'll change my IDE colors, it was clear as day when posting it here.

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.