examples:plugincoding:add_sidemenu

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
examples:plugincoding:add_sidemenu [2021/03/26 13:54]
pdsci-admin created
examples:plugincoding:add_sidemenu [2021/03/27 15:48] (current)
pdsci-admin [How to add a side menu item to a plugin]
Line 5: Line 5:
   - Here you will find (hopefully) the Plugin.php. Open this file in your editor   - Here you will find (hopefully) the Plugin.php. Open this file in your editor
   - add a public function called boot() if it does not already exist (should be so)   - add a public function called boot() if it does not already exist (should be so)
 +
 +<sxh php>
 +<?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'),
 +            ],
 +        ]);
 +    });
 +}
 +</sxh>