Hiding the Short Cut menu

bsoremsugar —  September 25, 2008 — 2 Comments

One of the things I’ve seen popping up on the Sugar forums lately is people looking for suggestions on hiding the left shortcut menu on their views. We do this in a number of places in the application, such as in Studio, Module Builder, in the AJAX Email client, and in step 3 of the Import module.

The most common approach I’ve seen discussed is to remove the contents of the side QuickCreate definitions. This will only remove the content of the menu, but doesn’t hide the actual menu from the view. The easier method is to hide the menu via JavaScript; doing this will allow you to simply default the menu to being hidden ( like we do the the aforementioned modules ) or you can completely remove it from the screen.

To have the menu start off hidden ( and preserve the users preference for having the menu visible or hidden ) add the following JavaScript code to display in the view.

<script type="text/javascript">

<!--

// hide the shortcut menu

if (!Get_Cookie('showLeftCol')) {

Set_Cookie('showLeftCol','true',30,'/','','');

}
var show = Get_Cookie('showLeftCol');

if ( document.getElementById('leftCol').style.display != 'none' ) {

hideLeftCol("leftCol");

closeMenus();

}
Set_Cookie('showLeftCol',show,30,'/','','');

-->

</script>

To not display the menu at all, add the following JavaScript code to the view instead:

<script type="text/javascript">

<!--

document.getElementById('leftCol').style.display = 'none';

document.getElementById('HideHandle').style.display = 'none';

-->

</script>

You can add this to output in the display() method of the view.  To learn how to override views, check out the Sugar Developer Guide.  Be sure to put your new view in the custom/ directory.

2 responses to Hiding the Short Cut menu

  1. 

    I was thinking of the easiest and most upgrade-safe way to implement this code. How about an ‘after_ui_frame’ business logic hook that echoes out the JavaScript above? I think this would then hit every screen in the app.

  2. 

    I was thinking of the easiest and most upgrade-safe way to implement this code. How about an ‘after_ui_frame’ business logic hook that echoes out the JavaScript above? I think this would then hit every screen in the app.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s