Ad

OctoberCMS - Extending The User Plugin's List Toolbar By Adding An Extra Button/link

- 1 answer

I've been extending October's User plugin with my own plugin that adds a few more fields using the method's outlined in their docs.

I've also added an option to export the user data using my own controller which works just fine. The problem I'm having is kinda the "easy" bit. All I need to do is add an extra "Export" button to the list toolbar at the top of the backend list view (markup at rainlab/user/controllers/users/_list_toolbar.htm). I just can't seem to find any function/event that I can hijack to either add a button in or replace the entire list_toolbar with my own.

Is there any way I can do this?

Ad

Answer

The author of this plugin needs to add a view event hook for extending the toolbar.

<?= $this->fireViewEvent('rainlab.user.extendUserToolbar') ?>

Otherwise you could consider adding the export link to the side navigation.

Event::listen('backend.menu.extendItems', function($manager) {
    $manager->addSideMenuItems('RainLab.User', 'user', [
        'export' => [
            'label'       => 'Export',
            'icon'        => 'icon-export',
            'url'         => Backend::url('path/to/your/export/controller'),
            'permissions' => ['rainlab.users.*'],
        ],
    ]);
});
Ad
source: stackoverflow.com
Ad