Upgrade-Safe way to hide subpanels

I’d like to hide subpanels on some of the modules. For example, for me an Opportunity or Project should be related to a Account only. Not a Lead or Contact. When I google, I see different options to modify the PHP code. I’m fine doing that, but I want to make sure whatever I do is upgrade safe.

What’s the best way to do this?

1 Like

Hi Mike,

If you don’t need the relationships there, you could just remove them?

Thanks,

Will.

Hi Mike,

Go to Admin->Studio->Accounts->Relationships

Delete the relationships you do not need. Many-to-many relationships create sub-panels.

Anything you do in Studio is upgrade safe.

Hi Guys, thanks for the responses. I maybe overcomplicating this, but I can’t get Studio to delete a relationship that already exists in the base install.

For example, I’d like to only show the BUGS subpanel on the PROJECT module. To me, and ACCOUNT or CONTACT cannot have bugs (figuratively speaking). For my workflow, I want to use BUGS as a way to store punch-list items as a project is wrapping up. Those little things that need to be fixed before a project can be closed.

If I hide BUGS on “Displayed Modules and Subpanels”, it hides the module everywhere. Not what I want as it’s hiding it from PROJECS.
If I go to Sudio->Accounts->Relationships, and edit the accounts_bugs relationship, it only allows me to change the labels doesn’t allow me a way to delete them.

Hi Mike,

A little googling gave me this.

http://forums.sugarcrm.com/f3/how-remove-custom-relationship-37781/

Please go through it, might be of some help.

I dont think you can remove the defualt relationships in sugar via studio. But you can hide a subpanel in an upgrade safe way by doing this:

For example in the accounts module

Create a new custom php file and add this code


unset($layout_defs['Accounts']['subpanel_setup']['accounts']);  

put the file inside custom/Extension/modules/Accounts/Ext/Layoutdefs/

Then remember to do a repair and rebuild.

Anything done in the custom folder should be upgrade safe.

1 Like

Much appreciated Andy, that worked perfectly and solved my issue:

For those who stumble on the post later, here is the command to hide the bugs and leads subpanel from the Accounts panel.

$cat ./custom/Extension/modules/Accounts/Ext/Layoutdefs/custom.php
unset($layout_defs['Accounts']['subpanel_setup']['bugs']);
unset($layout_defs['Accounts']['subpanel_setup']['leads']);
1 Like

How can I do this with the custom.php script on the ondemand version ?

Hi Bart,

Did you receive portal access details? If so, please create a case. If not, please let me know.

I will back to you on your questions asap.

Thanks,

Will.

Hello

I don’t understand. I made 2 tickets in the portal, but there the ticket is closed without solution.

Bart

How can I remove existing relations in modules eg . Accounts ? I want to remove the relation between accounts and documents do I can hide the documents subpanel on account detail… (since documents are only related to a custom module in my case). There is no delete button in the studio…
Same case for bugs (which I log on a custom module instead of on an account)

Really want to clean up ‘overhead’ in screens…

mikebruns99

looks like your copy/paste failed there.

unset($layout_defs);
unset($layout_defs);

Dear Andy,

the solution that you provided seems to be exactly the solution to the problem I have. Unfortunately I don’t get it. :unsure:

unset($layout_defs['Accounts']['subpanel_setup']['accounts']);

I want to remove the “Member Organizations” subpanel from the detailed Account view.
So how would I have to change your code to do so?
Or, the other way arroiund, what sub panel do you remove from what module, with the code that you’ve shown?
As ist says Accounts and accounts, I do not understand what the module’s name is and what the name of the sub panel.

I don’t want to remove any relationships, I only want to ged rid of some sub panels in some views, that can not be removed using studio.

Looking forward to hearing from you. - Thank you very much! :slight_smile:

Dear quarki69

I am not sure if you ever got this resolved but it is quite simple. I am using SuiteCRM 7.2.5 Beta

If you want to change the Sub panels in the Accounts View then you need to do the work here as this allows you to manipulate the Layout Definitions for the Accounts view

custom/Extension/modules/Accounts/Ext/Layoutdefs/myAccountsLayoutdefs.php

(you should create any of those subdirectories if they don’t exist yet)

Go all the way to the bottom of the file (then it is easy to find in future)

Step 1: Add a comment so you remember what you did

//Hide Subpanel view Leads & member Organizations

Step 2: Add the following 2 lines

unset($layout_defs['Accounts']['subpanel_setup']['leads']);
unset($layout_defs['Accounts']['subpanel_setup']['accounts']);

Step 3: Upload the folder back into the same spot

Step 4: Run “Repair and Rebuild” - which is in Admin->Repair

To understand the code is easy

unset($layout_defs['Accounts']['subpanel_setup']['accounts']); 
  • it is saying "Hide, in Acoounts, the Subpanel called leads

The next question you may have is how do I find the names of the subpanels I want to hide. That is also not hard go to

modules/Accounts/metadata/subpaneldefs.php and here you can spot the Subpanel name.

You can use the above logic for any Subpanel

5 Likes

Thanks a lot!!! I also did that.

unset($layout_defs['Contacts']['subpanel_setup']['contact_aos_quotes']);
unset($layout_defs['Contacts']['subpanel_setup']['contact_aos_invoices']);

this will unset the quotes and invoices on the contact module

Sorry to ask this in someone elses thread but it’s closely related.

Should this work with custom modules?

I have a custom module with subpanels but $layout_defs is an empty array, inside the metadata/subpanels folder for the module there is only default.php which I guess is the problem.

Right this works perfectly, until I find that certain modules don’t seem to have a layoutdefs such as the Calls module.

We don’t use ‘Leads’ at all, so going around unsetting it through each module and hiding it from nav menu display.

Unless it’s something like it’s not truly a module and the layout is defined elsewhere?

I can’t believe how long it took me to “get” this. :frowning: DCPaus is of course exactly right, but I wasn’t relating to it very well.

I wanted to hide the “activities, tasks & history” subpanels in the Accounts module.

None the less, for myself & the next person in step by step fashion.

Create a new (empty) file named custom.php in the /custom/Extension/modules/Accounts/Ext/Layoutdefs folder in your suitecrm directory.

The contents of the file are …

<?php
 // Remove activities & tasks from Accounts module (Ian Dodds)
unset($layout_defs['Accounts']['subpanel_setup']['activities']);
unset($layout_defs['Accounts']['subpanel_setup']['tasks']);
unset($layout_defs['Accounts']['subpanel_setup']['history']);
?>

Then do a “Quick Repair & Rebuild” from the repair selection in “Admin”

Following that, I also applied it to a custom module. (Copied the above custom.php file into the below directory & then edited the module name in the lines of code to suit.)

In my case the folder is /custom/Extension/modules/CER_ClientEquipment/Ext/Layoutdefs

(I opened one of the other files in this folder to get an accurate module name & copied that to replace the module name “Accounts” in the above example to my custom module name CER_ClientEquipment.)

The new code for my custom.php file is …

 <?php
 // Remove activities & tasks from Client Equipment module (Ian Dodds)
unset($layout_defs['CER_ClientEquipment']['subpanel_setup']['activities']);
unset($layout_defs['CER_ClientEquipment']['subpanel_setup']['tasks']);
unset($layout_defs['CER_ClientEquipment']['subpanel_setup']['history']);
?>

And then another “Quick Repair & Rebuild” from the repair selection in “Admin”

It worked as hoped in both scenario’s. I no longer see any of those 3 standard subpanels in either the Accounts module or my custom Client Equipment module.

SuitecRM Version 7.7.5

Gotta love computers :S :S :S

1 Like

I’m trying to follow the original steps in the Project modules but the file does not exist. Additionally, there is no LayoutDefs in Accounts, just Vardefs. Did something change and does anyone know to what?

Secondly, I also tried Doddsy’s method, with no change. Admittedly I’m not quite sure what you mean by an “empty” file with contents in it.