SugarCRM’s subpanels are pretty configurable. Especially in later editions, a single reference to a subpanel can be overridden via Studio very easily. But what if you want to all-out hide a subpanel? Studio doesn’t offer this ability. Enter the Display Module Tabs and Subpanels menu, accessible from the Admin page under the Developer Tools section:
But suppose you didn’t want to hide all of the subpanels for a given module, but just to remove it from a particular view? For a real-life example, we recently had a need to remove the default Opportunities subpanel from the Accounts DetailView. Because it’s only for this view that we want to drop the Opportunity subpanel, the above dialog doesn’t fit the need, and Studio cannot help us either. We must go through code.
Subpanel layouts are defined originally within metadata, e.g. /modules/Accounts/metadata/subpaneldefs.php. These files hold the original, default layout of subpanels and the fields within them. They are overridden in custom Extension data, e.g. custom/Extension/modules/Accounts/Ext/Layoutdefs/accounts_opps.php. After a repair & rebuild, you’ll find the data from the arbitrarily named files are merged and placed in /custom/modules/Accounts/Ext/Layoutdefs/layoutdefs.ext.php.
In these files we can define new subpanels or re-define existing ones. To actually remove one, we can use PHP’s unset function:
For further example, here is the described code, packaged and ready for distribution via Module Loader:
Accounts DetailView Hide Opp Subpanel