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

Zarkweb
Zarkweb

Hi, I'm currently struggling the backend menus for october plugins.

The situation:

  • I have a plugin with a top menu item and 4 sidebar items.
  • Each side menu item has its own permission.
  • The top menu item links to the first side menu item. Problem is that if the admin doesn't have tue permission required for the first submenu item, he can't see the top menu item at all even if he has permissions for other submenu items.

What I've tried so far:

I think I need an Index page for my plugin with no specific permission required. To do so, I tried to inspect the code of the "cms" menu which seems to use a generic index. Everything I have tried to point to a custom index have failed. Here is the code from my last atempt, can you guide me to through the good way of doing what I'm trying ?

 public function registerNavigation()
    {
        return [
            'bipage' => [
                'label' => 'elipce.bipage::lang.plugin.name',
                'url' => Backend::url('elipce/bipage/index'),
                'icon' => 'icon-files-o',
                'permissions' => ['elipce.bipage.*'],
                'order' => 20,

                'sideMenu' => [
                    'index' => [
                        'label' => 'elipce.bipage::lang.plugin.name',
                        'icon' => 'icon-files-o',
                        'url' => Backend::url('elipce/bipage/index'),
                        'permissions' => ['elipce.bipage.*']
                    ],
                    'pages' => [
                        'label' => 'elipce.bipage::lang.plugin.menus.pages',
                        'icon' => 'icon-files-o',
                        'url' => Backend::url('elipce/bipage/pages'),
                        'permissions' => ['elipce.bipage.manage_pages']
                    ],
                    'dashboards' => [
                        'label' => 'elipce.bipage::lang.plugin.menus.dashboards',
                        'icon' => 'icon-area-chart',
                        'url' => Backend::url('elipce/bipage/dashboards'),
                        'permissions' => ['elipce.bipage.edit_dashboards']
                    ],
                    'collections' => [
                        'label' => 'elipce.bipage::lang.plugin.menus.collections',
                        'icon' => 'icon-archive',
                        'url' => Backend::url('elipce/bipage/collections'),
                        'permissions' => ['elipce.bipage.manage_collections']
                    ],
                    'folders' => [
                        'label' => 'elipce.bipage::lang.plugin.menus.folders',
                        'icon' => 'icon-folder-o',
                        'url' => Backend::url('elipce/bipage/folders'),
                        'permissions' => ['elipce.bipage.manage_folders']
                    ]
                ]
            ]
        ];

With everything I've tried, I get a 404 not found on the top menu item. The "Index" controller exists and here is it's constructor if it can help :

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

        BackendMenu::setContext('Elipce.BiPage', 'bipage', 'index');
    }
KurtJensen
KurtJensen

Try change the URL from:

'url' => Backend::url('elipce/bipage/index'),

to

'url' => Backend::url('elipce/bipage/nameOfController'),

I believe the proper URL is like:

'url' => Backend::url('author/plugin/nameOfController/ControllerMethod'),
Zarkweb
Zarkweb

Thanks a lot for these clarifications !

It works indeed, I now understand better the backend link creation =)

Last updated

1-3 of 3

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