Wednesday, August 10, 2011

SugarCRM - Removing Buttons from a Subpanel

I needed to remove the buttons from a couple of subpanels in SugarCRM.  The process to do this was little convoluted  but I finally figured out all of the pieces I needed to modify.  Here is the process for removing the buttons on a subpanel for my Contacts module in the Accounts module.

The first thing that I had to do was copy the default subpanel layout file over to the custom directory so I could modify it.  Since I was modifying the Contacts subpanel, I copied the modules/Contacts/metadata/subpanels/default.php file over to custom/modules/Contacts/metadata/subpanels/default.php.  I then renamed the file to ForAccounts.php.  I did this so i would not be overwriting the default subpanel layout.  The reason I moved it to the custom directory was to make sure that this was upgrade safe.

Now, I opened ForAccounts.php and changed the part of it that defined the buttons.  In mine, I had the following:


  'top_buttons' =>
  array (
    0 =>
    array (
      'widget_class' => 'SubPanelTopCreateButton',
    ),
    1 =>
    array (
      'widget_class' => 'SubPanelTopSelectButton',
      'popup_module' => 'People',
    ),
  ),


I changed this to


  'top_buttons' =>
  array (),

I then saved my changes.

Now that I have a new definition, I have to let the subpanel know to use it.  In order to do this, you have to edit the subpanel file in the module.  For the accounts module, this is located in custom/Extension/modules/Accounts/Ext/Layoutdefs/. Look at the files and find the one that defines your subpanel.  For me, it was contacts_accounts_Accounts.php.

In this file you will need to edit the subpanel_name field.  You will need to change the value of it to what you called your new file above.  For me in this example, I would change it to ForAccounts.

'subpanel_name' => 'ForAccounts',

Also, you will need to take out the code that defines the buttons in this file.  So, make sure you delete the top_buttons field.

  'top_buttons' =>
  array (
    0 =>
    array (
      'widget_class' => 'SubPanelTopButtonQuickCreate',
    ),
    1 =>
    array (
      'widget_class' => 'SubPanelTopSelectButton',
      'mode' => 'MultiSelect',
    ),
  ),

I then did a Quick Repair and Rebuild from the Repair link in the Admin module.

This got rid of the buttons at the top of the subpanel.


No comments:

Post a Comment