Is there a way to hide the entire CMS menu pane for Edit Detail view when loaded in a popup window?

Silverstripe Version: 4.13


I have some js which opens a popup window displaying the edit details view for a new data object. I’m able to populate fields using:

public function populateDefaults() {
        // check if date has been passed in from calendar
        $date = Controller::curr()->getRequest()->getVar("DateTimeStart");
        if ($date != null) {
            $this->DateTimeStart = date($date . ' H:i:s');
            $this->DateTimeEnd = date($date . ' H:i:s');

This is all working fine, but I’m wondering whether there’s a way to hide the entire CMS menu for the popup so that it is less cluttered and users can’t navigate away from it. Is it possible to pass in a request variable to enable hiding the CMS menu, eg.


I’d then also want to change what happens when a user clicks the cancel button, the window is simply closed (rather than navigating to the events model admin).

I’ve tried hiding the menu panel using js by adding class “hide” or style “display:none;” to id=“cms-menu” (works in browser web inspector), however this is somehow being overridden in the new window.

Any help is much appreciated.

Assuming your “popup” is just displaying a regular ModelAdmin edit form or similar, there’s no built-in way to optionally hide the left menu, no.

Others have worked around this by subclassing the ModelAdmin, CMSMain or whatever class it is you’re dealing with and providing customised templates for their subclass. The customised templates don’t render the left menu.

You might be able to get away with just providing custom templates without any subclassing of PHP classes and using an extension to optionally use your custom templates when a specific parameter is included in the URL.

You could also try using form schema in a custom controller to render the form for you - you might look at silverstripe/silverstripe-linkfield as an example of doing that.

1 Like

Got it working with a model admin extension. In case this is useful to anyone else…

use SilverStripe\Control\Controller;
use SilverStripe\Core\Extension;
use SilverStripe\View\Requirements;

class ModelAdminExtension extends Extension {

    public function onAfterInit() {
        // load scripts and styles for popup windows when request variable (?popup=1) present
        $hide = Controller::curr()->getRequest()->getVar("popup");
        if ($hide == true) {
            Requirements::javascript('/js/popup.js',['defer' => true]);