examples:plugincoding:add_sidemenu

Back to Start Page

Here are the steps to take:

  1. Go to the plugin folder to add the menu item to. Let's assume this plugin is created by “pds” and the name of the plugin is 'library'. So the plugin is to be found at [path to octobercms]/plugins/pds/library/
  2. Here you will find (hopefully) the Plugin.php. Open this file in your editor
  3. add a public function called boot() if it does not already exist (should be so)

<?php
...

public function boot()
{
    // Extend the backend side navigation for a plugin
    Event::listen('backend.menu.extendItems', function($manager) {
    
       // Pds.Library stands for author.pluginname
       // Library is the main entry for this plugin shown at the top menu
       $manager->addSideMenuItems('Pds.Library', 'Library', [
            'books' => [
                'label'       => 'Books',
                'icon'        => 'icon-book',
                'code'        => 'side-menu-books',
                'owner'       => 'Pds.Library',
                'url'         => Backend::url('Pds/Library/Books'),
            ],
        ]);
    });
}