1

Is there a way to toggle the left/sidebar admin menu altogether, like VSCode or SublimeText?

It'd be great to only display the sections & entries on certain occasions. This comes in handy especially if there are several columns selected in a particular section.

Thanks in advance!

Jae Barclay
  • 123
  • 5

1 Answers1

3

There's no built-in way to do this, but you can build that functionality into a module. This will inject some CSS to all CP requests that will remove the sidebar and make the page container span the entire page:

/** @var craft\web\View $view */
$view = Craft::$app->getView();

if (Craft::$app->getRequest()->getIsCpRequest()) { $view->registerCss(<<<'CSS' #global-sidebar { display: none; } body.ltr #page-container { padding-left: 0; } #main-content { width: 100vw; } CSS); }

(Will need some adjustments if you need to support rtl languages.)

Now this alone is not particularly useful, but you can make it more dynamic depending on your requirements:

  • To limit this to particular user groups, you can use the Control Panel Body Classes plugin and scope the CSS to a particular user group class.
  • If you want to have an on/off toggle, you can inject some JavaScript (see View::registerJs) that adds a floating button to toggle the above CSS on click.
MoritzLost
  • 11,215
  • 5
  • 22
  • 1
    That sounds good. I think I can get away with injecting CSS or simply using the plugin you suggested.

    Much appreciate the reply!

    – Jae Barclay Aug 03 '22 at 12:37
  • @JaeBarclay If this solved your issue, would you mind marking my answer as accepted? Thanks. – MoritzLost Aug 03 '22 at 12:49