Skip to content

Plugin Dev: RegisterCpNavItemsEvent #1838

@mcmadafly

Description

@mcmadafly

Description

Attempting to allow my plugin to display as a navigation element in the CP area but I can't get it to work.

I used Redirect as a working example and I've included the code I borrowed below.

Plugin is installed and is working as it should. I can navigate to the CP index page but it will not display the icon and nav element in the sidebar.

I didn't see this anywhere in the docs (I could have missed it) so I'm posting here.

Steps to reproduce

  1. Germinated plugin scaffold from https://pluginfactory.io/
  2. Added the following code to the plugin:
    use craft\events\RegisterCpNavItemsEvent;
    
    // ...
    
    public function getCpNavItem()
    {
        return [
            'url'=> 'pluginurl',
            'label'=>Craft::t('plugin', 'Plugin'),
            'icon' => 'icon'
        ];
    }

Additional info

  • Craft version: Craft CMS 3.0.0-beta.22
  • PHP version: 7.0.15
  • Database driver & version: MySQL 5.6.35
  • Plugins & versions: This custom plugin, Redirect as an example

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions