Created
September 14, 2012 15:47
-
-
Save sugarknowledge/3722771 to your computer and use it in GitHub Desktop.
How To Dynamically Hide Subpanels Based on Record Values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); | |
//Points to 'modules/Accounts/views/view.detail.php' instead of 'include/MVC/View/views/view.detail.php' since accounts already overrides the stock view | |
//require_once('include/MVC/View/views/view.detail.php'); | |
require_once('modules/Accounts/views/view.detail.php'); | |
class CustomAccountsViewDetail extends AccountsViewDetail | |
{ | |
function CustomAccountsViewDetail() | |
{ | |
parent::AccountsViewDetail(); | |
} | |
/** | |
* Override - Called from process(). This method will display subpanels. | |
*/ | |
protected function _displaySubPanels() | |
{ | |
if (isset($this->bean) && !empty($this->bean->id) && (file_exists('modules/' . $this->module . '/metadata/subpaneldefs.php') || file_exists('custom/modules/' . $this->module . '/metadata/subpaneldefs.php') || file_exists('custom/modules/' . $this->module . '/Ext/Layoutdefs/layoutdefs.ext.php'))) { | |
$GLOBALS['focus'] = $this->bean; | |
require_once ('include/SubPanel/SubPanelTiles.php'); | |
$subpanel = new SubPanelTiles($this->bean, $this->module); | |
//Dependent logic | |
if ($this->bean->account_type == 'Analyst') | |
{ | |
//Subpanels to hide | |
$hideSubpanels=array( | |
'contacts', | |
'leads', | |
'documents', | |
'cases', | |
); | |
foreach ($hideSubpanels as $subpanelKey) | |
{ | |
//Remove subpanel if set | |
if (isset($subpanel->subpanel_definitions->layout_defs['subpanel_setup'][$subpanelKey])) | |
{ | |
unset($subpanel->subpanel_definitions->layout_defs['subpanel_setup'][$subpanelKey]); | |
} | |
} | |
} | |
echo $subpanel->display(); | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment