Remove a Tab, keep the Subpanel

bsoremsugar —  April 21, 2009 — 16 Comments

I was speaking with one of Sugar’s stellar Customer Support Engineers today when we came up with this little tid bit…

The problem:

The customer wanted to remove the Opportunities tab, but keep it as a subpanel in a detailview – oh and make it upgrade safe.

The solution:

The modules that are displayed or hidden are (for the most part) by include/modules.php

If you view include/modules.php, you’ll notice that there are multiple arrays.  Most importantly, there is a way (at the very end) to override this file:


if (file_exists('include/modules_override.php'))

{

include('include/modules_override.php');

}

if (file_exists('custom/application/Ext/Include/modules.ext.php'))

{

include('custom/application/Ext/Include/modules.ext.php');

}

I prefer to keep all customizations in the “custom” directory – so let’s use .custom/application/Ext/Include/modules.ext.php

After creating the file, this is the code we added:




The critical array here is “$modules_exempt_from_availability_check”.  This array adds the subpanel back into the view.

Also, it’s worth noting the gymnastics we used to unset the array.  That’s because you need to unset it by the array’s index….  Because it’s possible that we someone else could put “Opportunities” in the moduleList array multiple times, we loop through it.

Finally, to date (the 5.2.0c), modules.ext.php would get over-written by Module Builder if you deploy a module.  That means, if you make a module, this custom code would get destroyed.  The simple solution, is to put it in the other place -> include/modules_override.php.  While that’s safe, it’s keeping custom code out of the custom directory.  A bug has been filed and we’ll see a fix in future releases.

If you can think of ways that will help create better hooks for customizations in the custom directory, please let us know!  We’re always looking for ways to make Sugar even more upgrade safe with customizations.

16 responses to Remove a Tab, keep the Subpanel

  1. 

    I haven’t tried this but I think that you can’t use Opportunities in Reports if you add the module to modInvisList.

  2. 

    I haven’t tried this but I think that you can’t use Opportunities in Reports if you add the module to modInvisList.

  3. 

    A thing that would greatly help me is to have hook after a record is related to another record, when pressing “Select” in a sub-panel.

  4. 

    A thing that would greatly help me is to have hook after a record is related to another record, when pressing “Select” in a sub-panel.

  5. 
    Daniel Reverri April 22, 2009 at 7:33 pm

    Looks like Report modules are determined in modules/Reports/config.php by the function getAllowedReportModules().

    The function uses $modListHeader to determine which modules to report on with a few hard coded exceptions:
    $subModuleCheckArray = array(“Tasks”, “Calls”, “Meetings”, “Notes”);
    $subModuleProjectArray = array(“ProjectTask”);

    I suppose you could add Opportunities to the $subModuleCheckArray to force Opportunities to show in Reports but this would not be upgrade safe.

  6. 

    Looks like Report modules are determined in modules/Reports/config.php by the function getAllowedReportModules().

    The function uses $modListHeader to determine which modules to report on with a few hard coded exceptions:
    $subModuleCheckArray = array(“Tasks”, “Calls”, “Meetings”, “Notes”);
    $subModuleProjectArray = array(“ProjectTask”);

    I suppose you could add Opportunities to the $subModuleCheckArray to force Opportunities to show in Reports but this would not be upgrade safe.

  7. 

    Working off of Dan’s suggestion, you could add the following code around line 98 of ./modules/Reports/config.php:

    $report_modules[‘Opportunities’]=’Opportunity';

    This would add the module back to the report module and as Dan stated, is not upgrade safe. Ideally, I think it would be best to check for a config_override.php for any instance we include this config.php file.

  8. 

    Working off of Dan’s suggestion, you could add the following code around line 98 of ./modules/Reports/config.php:

    $report_modules[‘Opportunities’]=’Opportunity';

    This would add the module back to the report module and as Dan stated, is not upgrade safe. Ideally, I think it would be best to check for a config_override.php for any instance we include this config.php file.

  9. 

    Hi,

    Thanks for this tip.
    I think there is a mistake in your sample code. I tried it and it makes exceptions…
    This is the code I fixed (in the foreach loop) :

    unset($moduleList[$modulekey[$value]]);

    becomes :

    unset ($moduleList[$value]);

    Thanks again,

    Sam

  10. 

    Hi,

    Thanks for this tip.
    I think there is a mistake in your sample code. I tried it and it makes exceptions…
    This is the code I fixed (in the foreach loop) :

    unset($moduleList[$modulekey[$value]]);

    becomes :

    unset ($moduleList[$value]);

    Thanks again,

    Sam

  11. 

    Hi,
    Another precision, this method seems to disable relative quick actions links in the side bar.
    The only solution I found to hide the module from the tabbar while keeping the module functionalities is by unsetting the $modListHeaderClone entry in the “header.php”…

    This method is unfortunatly not upgrade safe.

    If somebody has another solution…

    ++

    Sam

  12. 

    Hi,
    Another precision, this method seems to disable relative quick actions links in the side bar.
    The only solution I found to hide the module from the tabbar while keeping the module functionalities is by unsetting the $modListHeaderClone entry in the “header.php”…

    This method is unfortunatly not upgrade safe.

    If somebody has another solution…

    ++

    Sam

  13. 

    Quick correction

    foreach($modulekey as $key => $value){

    should be
    foreach($modulekey as $key => $value){

  14. 

    Quick correction

    foreach($modulekey as $key => $value){

    should be
    foreach($modulekey as $key => $value){

  15. 

    You did an excellent job, dude!

  16. 

    I applied this hoping that if i commented out $modules_exempt_from_availability_check that it would hide the subpanel as well after reading this “The
    critical array here is “$modules_exempt_from_availability_check”.  This
    array adds the subpanel back into the view.” — however it did not hide
    the subpanel.. which is what i would like to do lol can anyone help?

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