Robert Caverly

Standardizing Subpanel Ordering for All Users

Discussion created by Robert Caverly on Dec 22, 2015

According to this web page it is not possible to explicitly set the order of sub-panels in a detail view; it must be done by each user individually.

 

I have come up with a fairly simple way to actually accomplish this in a simple customization which can be implemented on a per module basis and is upgrade safe.

 

The file /custom/modules/<module>/Ext/Layoutdefs/layoutdefs.ext.php contains the "definition" of each sub-panel for a given module's detail view. The arrays defined in this file contain an element 'order' which is defaulted to 100 for all sub-panels.  Changing this value for each subpanel will modify the display order accordingly, providing a simple way to control the sub-panel order! Easy solution? Unfortunately, not so much -- this is an auto-generated file and any changes you make here will be over-written any time you run Quick Repair.

 

There is a simple way to leverage this however! Create a custom file /custom/modules/<module>/views/view.detail.php and you can add the code to explicitly order the subpanels according to whatever scheme is appropriate.  In the example code below I have created a helper function to explicitly order subpanels in a fixed order - however, you could also add additional logic to selectively order subpanels, or change other attributes before display.

 

<?php

 

if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

 

require_once('include/MVC/View/views/view.detail.php');

require_once ('include/SubPanel/SubPanelTiles.php');

 

class modulenameViewDetail extends ViewDetail {

 

     function ViewDetail(){

        parent::ViewDetail();

     }

 

     function display()

     {

        if(empty($this->bean->id)){

            global $app_strings;

            sugar_die($app_strings['ERROR_NO_RECORD']);

        }

 

        $this->dv->process();

        echo $this->dv->display();

     }

 

     /**

     * order subpanels explicitly

     */

     function _displaySubPanels()

     {

        require_once ('include/SubPanel/SubPanelTiles.php');

        $subpanel = new SubPanelTiles($this->bean, $this->module);

 

        $this->order_subpanels($subpanel->subpanel_definitions->layout_defs['subpanel_setup']);

 

        echo $subpanel->display();

     }

    

     function order_subpanels(&$subpanel_setup) {

         $subpanel_setup['modulename_subpanelmodulename1']['order'] = 100;

         $subpanel_setup['modulename_subpanelmodulename2']['order'] = 200;

         $subpanel_setup['modulename_subpanelmodulename3']['order'] = 300;

         $subpanel_setup['modulename_subpanelmodulename4']['order'] = 400;

         $subpanel_setup['modulename_subpanelmodulename5']['order'] = 500;

     }

}

 

Be sure to update the highlighted code with the appropriate module and subpanel names!

 

Hope this helps somebody else!

Outcomes