Adding/Modifying the Shortcuts Menu

bsoremsugar —  June 29, 2009 — 10 Comments

Adding/Modifying the Shortcuts Menu

Suppose you want to modify the Opportunities Shortcuts menu to add a shortcut to create a new Lead (not tied to the existing opportunity).

Create a custom file called:

/custom/Extension/modules/Opportunities/Ext/Menus/CustomMenu.php

The filename is not very important.  Add the following contents:
<?php

if(ACLController::checkAccess(‘Leads’, ‘edit’, true))$module_menu[]=Array(“index.php?module=Leads&action=EditView&return_module=Opportunities&return_action=ListView”, “New From Canvass Form”,”CreateNotes”, ‘Leads’);

?>

Lets’s look at this code to see what it does.
if(ACLController::checkAccess(‘Leads’, ‘edit’, true))

This line of code checks to see if the user has access to the Leads module.  If they do then the system will all another shortcut menu.  This is not strictly required, but good coding practice so users don’t see menu items for modules they can’t create or edit.

The variable $module_menu contains the items the information used to create the menus.  The format is

$module_menu[]=Array($url,$menu_title,$image_icon,$module)

$url – this is where you want to go.  You can look at <install dir>/<ModuleName>/Menu.php to see the shortcuts for the existing modules

$menu_title – In this example, I hard coded the name to “New from Canvass Form”.  If you want the application to be multi-lingual and conform to Sugar standards, you should add a custom string and use something like $mod_strings[‘LNK_NEW_FROM_CANVASS_FORM’]

$image_icon – The images are found in themes/default/images.  If you want to add a new icon, put it there.

$module – The name of the module

You must do a Quick Repair and Rebuild for this to take effect.

If you want to not show the out of the box shortcut menu items, you can just redeclare the array.  Putting the following code in your cusotm file:

<?php

$module_menu= array();

if(ACLController::checkAccess(‘Leads’, ‘edit’, true))$module_menu[]=Array(“index.php?module=Leads&action=EditView&return_module=Opportunities&return_action=ListView”, “New From Canvass Form”,”CreateNotes”, ‘Leads’);

?>

will have only 1 shortcut item.

10 responses to Adding/Modifying the Shortcuts Menu

  1. 

    It’s a bit brutal, but removing just one link from the menu can be achieved by unsetting that exact key from the array:

    unset($module_menu[1]);

    Off course, the menu mustn’t change or this can begin to cause troubles in the menu. Something like this should also work:

    foreach($module_menu AS &$item) {
    if($item === array(”index.php?module=Leads&action=EditView&return_module=Opportunities&return_action=ListView”, “New From Canvass Form”,”CreateNotes”, ‘Leads’)) {
    unset($item);
    }
    }

  2. 

    It’s a bit brutal, but removing just one link from the menu can be achieved by unsetting that exact key from the array:

    unset($module_menu[1]);

    Off course, the menu mustn’t change or this can begin to cause troubles in the menu. Something like this should also work:

    foreach($module_menu AS &$item) {
    if($item === array(”index.php?module=Leads&action=EditView&return_module=Opportunities&return_action=ListView”, “New From Canvass Form”,”CreateNotes”, ‘Leads’)) {
    unset($item);
    }
    }

  3. 

    It is amazing that this is still not possible via the web configuration interface? Seriously guys, there really should be a way to move this into the studio.

  4. 

    It is amazing that this is still not possible via the web configuration interface? Seriously guys, there really should be a way to move this into the studio.

  5. 

    I’m testing this in 6.1 and i dont seem to be able to remove menu items as described. Is this a bug?

  6. 

    Is there a way to remove the “Create” shortcut but the user can still edit the record assigned to him?

    • 

      Would you be looking to remove the shortcut for all users, or just users with a certain role/team/etc?

      • 

        Its for a certain user only. I can’t control it on the role since there is no role that restricts the create function of a record. I’ve managed to find a workaround using the getMenu() function but this should be implemented to all the views.

Trackbacks and Pingbacks:

  1. Adding to the shortcut menu - February 21, 2013

    […] […]

  2. Changing subModuleList functionality - April 22, 2013

    […] […]

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