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

jasonwong
jasonwong

How to change the default menu of backend with plugins?

I just found a way to add a menu, but I want to change the settings menu, for example: change the link to another link of backend preferences, or simply delete it. i.e.

Can be do it through the plugin? I need any directions. thanks!

jfo
jfo

You can listen to the backend.menu.extendItems event to change menu items.

Example, changing the label text for the Settings menu:

class Plugin extends PluginBase
{
    public function boot()
    {
        \Event::listen('backend.menu.extendItems', function($manager) {
            $manager->addMainMenuItems('October.System', [
                'system' => [
                    'label' => 'Settings label modified to a new text',
                    'icon' => 'icon-users',
                ]
            ]);

You could also remove the Settings menu:

$manager->removeMainMenuItem('October.System', 'system');

More details here: https://octobercms.com/docs/plugin/extending#extending-backend-menu

rafael15889
rafael15889

Starting from this solution: ¿How can I remove the settings menu only for a user?

jfo
jfo

@rafael15889 you can access the current logged in user and apply your own conditions to test if that user should or not see the settings menu.

Example:


        \Event::listen('backend.menu.extendItems', function($manager) {
            $user = \BackendAuth::getUser(); // get the logged in user

            if ($user->anyUserModelPropertyYouWouldLikeToCompare == 'your value') {
                // removes settings menu
                $manager->removeMainMenuItem('October.System', 'system');
            }
        });

1-4 of 4

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