id
stringlengths
14
16
text
stringlengths
33
5.27k
source
stringlengths
105
270
03b2aa7c2e73-9
'components' => [ [ 'view' => [ 'name' => 'greeting-nav-item', 'type' => 'greeting-nav-item', 'route' => '#Accounts', ... ], ], ], ], ];   The following components define how the Sidebar/Rail layout is displayed. Home The first group before the line/divisor contains the "hamburger" icon menu whose sole purpose is to expand/collapse the side nav. The second group contains: Home menu dedicated to Dashboards Quick Create menu dedicated to creating new records Home Menu
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/MainLayout/index.html
03b2aa7c2e73-10
Home menu dedicated to Dashboards Quick Create menu dedicated to creating new records Home Menu The Home menu view is composed of the sidebar-nav-flyout-module-menu (responsible to display the Secondary Action menus with dashboards and recent items), sidebar-nav-item-module (responsible to display the menu's title) views. To customize these components, you can create your own layout by extending them at ./custom/Extension/application/Ext/custom/clients/base/views and locating its folder with the same name for your own custom components. Quick Create   Quick Create view has been redesigned and presents the modules on click. Note this view does not require secondary action as others do with submenu Quick Create View
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/MainLayout/index.html
03b2aa7c2e73-11
Note this view does not require secondary action as others do with submenu Quick Create View The Quick Create view is composed of the sidebar-nav-item-quickcreate (responsible to display the Quick Create menu and its icon), sidebar-nav-flyout-header (responsible to display the menu's title) and sidebar-quickcreate (responsible to display Secondary Action/submenu) views. To customize these components, you can create your own layout by extending them at ./custom/Extension/application/Ext/custom/clients/base/views and locating its folder with the same name for your own custom components. Modules
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/MainLayout/index.html
03b2aa7c2e73-12
Modules The Modules layout, located in ./clients/base/layouts/sidebar-nav-item-group-modules/sidebar-nav-item-group-modules.js, contains the logic to load modules metadata, build the module list and display them accordingly depending on the Sidebar/Rail state (expanded or collapsed) as well as respect the Pinned Items and order it should be displayed. To customize this component, you can create your own by extending it at ./custom/Extension/application/Ext/custom/clients/base/layouts/sidebar-nav-item-group-modules/sidebar-nav-item-group-modules.js, to reference your own custom logic and make sure you extend from the view SidebarNavItemModuleView or layout SidebarNavItemGroupModulesLayout   Â
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/MainLayout/index.html
03b2aa7c2e73-13
    if (isset($viewdefs['<module>']['base']['menu']['header'])) { foreach ($viewdefs['<module>']['base']['menu']['header'] as $key => $moduleAction) { //remove the link by label key if (in_array($moduleAction['label'], array('<link label key>'))) { unset($viewdefs['<module>']['base']['menu']['header'][$key]); } } } Once you have created the extension files, navigate to Admin > Repair > Quick Repair and Rebuild. This will remove the menu action item from the existing list of links.   Profile Action Links
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/MainLayout/index.html
03b2aa7c2e73-14
  Profile Action Links Profile actions are the links listed under the user's profile menu on the right side of the Top Header. Profile action extension files are located in ./custom/Extension/application/Ext/clients/base/views/profileactions/ and are compiled into  ./custom/application/Ext/clients/base/views/profileactions/profileactions.ext.php. Adding Profile Action Links The example below demonstrates how to add a profile action link to the Styleguide. To define your own profile action link, create your own label extension for the link's display label.  ./custom/Extension/application/Ext/Language/en_us.addProfileActionLink.php <?php //create the links label $app_strings['LNK_STYLEGUIDE_C'] = 'Styleguide';
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/MainLayout/index.html
03b2aa7c2e73-15
Next, create the profile action link extension: ./custom/Extension/application/Ext/clients/base/views/profileactions/addProfileActionLink.php <?php $viewdefs['base']['view']['profileactions'][] = array( 'route' => '#Styleguide', 'label' => 'LNK_STYLEGUIDE_C', 'icon' => 'icon-link', ); Once you have created the extension files, navigate to Admin > Repair > Quick Repair and Rebuild. This will append your profile action item to the existing list of links. Note: You may need to refresh the page to see the new profile menu items. Removing Profile Action Links
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/MainLayout/index.html
03b2aa7c2e73-16
Removing Profile Action Links To remove a profile action link, loop through the list of profile actions and remove the item by one of its properties. For your reference, the stock profile actions can be found in ./clients/base/views/profileactions/profileactions.php. ./custom/Extension/application/Ext/clients/base/views/profileactions/removeProfileActionLink.php <?php if (isset($viewdefs['base']['view']['profileactions'])) { foreach ($viewdefs['base']['view']['profileactions'] as $key => $profileAction) { //remove the link by label key if (in_array($profileAction['label'], array('LNK_ABOUT'))) { unset($viewdefs['base']['view']['profileactions'][$key]);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/MainLayout/index.html
03b2aa7c2e73-17
} } } Once you have created the extension files, navigate to Admin > Repair > Quick Repair and Rebuild. This will remove the profile action item from the existing list of links. Note: You may need to refresh the page to see the profile menu items removed. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/MainLayout/index.html
130008d04360-0
Administration Links Overview Administration links are the shortcut URLs found on the Administration page in the Sugar application. Developers can create additional administration links using the extension framework. The global links extension directory is located at ./custom/Extension/modules/Administration/Ext/Administration/. After a Quick Repair and Rebuild, the PHP files in this directory are compiled into ./custom/modules/Administration/Ext/Administration/administration.ext.php. Additional information on this can be found in the extensions Administration section of the Extension Framework documentation. The current links defined in the administration section can be found in ./modules/Administration/metadata/adminpaneldefs.php. Example The following example will create a new panel on the Admin page: ./custom/Extension/modules/Administration/Ext/Administration/<file>.php <?php
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Administration_Links/index.html
130008d04360-1
<?php $admin_option_defs = array(); $admin_option_defs['Administration']['<section key>'] = array( //Icon name. Available icons are located in ./themes/default/images 'Administration', //Link name label 'LBL_LINK_NAME', //Link description label 'LBL_LINK_DESCRIPTION', //Link URL - For Sidecar modules 'javascript:void(parent.SUGAR.App.router.navigate("<module>/<path>", {trigger: true}));', //Alternatively, if you are linking to BWC modules //'./index.php?module=<module>&action=<action>', );
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Administration_Links/index.html
130008d04360-2
); $admin_group_header[] = array( //Section header label 'LBL_SECTION_HEADER', //$other_text parameter for get_form_header() '', //$show_help parameter for get_form_header() false, //Section links $admin_option_defs, //Section description label 'LBL_SECTION_DESCRIPTION' ); To define labels for administration links in the new panel: ./custom/Extension/modules/Administration/Ext/Language/en_us.<name>.php <?php $mod_strings['LBL_LINK_NAME'] = 'Link Name'; $mod_strings['LBL_LINK_DESCRIPTION'] = 'Link Description';
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Administration_Links/index.html
130008d04360-3
$mod_strings['LBL_SECTION_HEADER'] = 'Section Header'; $mod_strings['LBL_SECTION_DESCRIPTION'] = 'Section Description'; Finally, navigate to Admin > Repair > Quick Repair and Rebuild. The system will then rebuild the extensions and the panel will appear on the Admin page. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Administration_Links/index.html
3f5d36a01e7c-0
Legacy MVC Overview The legacy MVC Architecture. You should note that the MVC architecture is being deprecated and is being replaced with sidecar. Until the framework is fully deprecated, modules set in backward compatibility mode will still use the MVC framework. Model-View-Controller (MVC) Overview A model-view-controller, or MVC, is a design philosophy that creates a distinct separation between business-logic and display logic. Model : This is the data object built by the business/application logic needed to present in the user interface. For Sugar, it is represented by the SugarBean and all subclasses of the SugarBean. View : This is the display layer which is responsible for rendering data from the Model to the end-user.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/index.html
3f5d36a01e7c-1
Controller : This is the layer that handles user events such as "Save" and determines what business logic actions to take to build the model, and which view to load for rendering the data to end users. SugarCRM MVC Implementation The following is a sequence diagram that highlights some of the main components involved within the Sugar MVC framework.   TopicsViewDisplaying information to the browser.ControllerThe basic actions of a module.MetadataAn overview of the legacy MVC metadata framework.ExamplesProvides an overview of example MVC customizations. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/index.html
8877de60358e-0
Controller Overview The basic actions of a module. Controllers The main controller, named SugarController, addresses the basic actions of a module from EditView and DetailView to saving a record. Each module can override this SugarController by adding a controller.php file into its directory. This file extends the SugarController, and the naming convention for the class is: <module>Controller Inside the controller, you define an action method. The naming convention for the method is: action_<action name> There are more fine-grained control mechanisms that a developer can use to override the controller processing. For example, if a developer wanted to create a new save action, there are three places where they could possibly override. action_save: This is the broadest specification and gives the user full control over the save process. pre_save: A user could override the population of parameters from the form.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Controller/index.html
8877de60358e-1
pre_save: A user could override the population of parameters from the form. post_save: This is where the view is being set up. At this point, the developer could set a redirect URL, do some post-save processing, or set a different view. Upgrade-Safe Implementation You can also add a custom Controller that extends the module's Controller if such a Controller already exists. For example, if you want to extend the Controller for a module, you should check if that module already has a module-specific controller. If so, you extend from that controller class. Otherwise, you extend from SugarController class. In both cases, you should place the custom controller class file in ./custom/modules/<module>/Controller.php instead of the module directory. Doing so makes your customization upgrade-safe. File Structure ./include/MVC/Controller/SugarController.php ./include/MVC/Controller/ControllerFactory.php
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Controller/index.html
8877de60358e-2
./include/MVC/Controller/ControllerFactory.php ./modules/<module>/Controller.php ./custom/modules/<module>/controller.php Implementation If the module does not contain a controller.php file in ./modules/<module>/, you will create the following file: ./custom/modules/<module>/controller.php class <module>Controller extends SugarController { function action_<action>() { $this->view = '<action lowercase>'; } } If the module does contain a controller.php file, you will need to extend it by doing the following: ./custom/modules/<module>/controller.php require_once 'modules/<module>/controller.php'; class Custom<module>Controller extends <module>Controller { function action_<action>() {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Controller/index.html
8877de60358e-3
{ function action_<action>() { $this->view = '<action lowercase>'; } } Note: When creating or moving files you will need to rebuild the file map. More information on rebuilding the file map can be found in the SugarAutoLoader. Mapping Actions to Files You can choose not to provide a custom action method as defined above, and instead, specify your mappings of actions to files in $action_file_map. Take a look at ./include/MVC/Controller/action_file_map.php as an example: $action_file_map['subpanelviewer'] = 'include/SubPanel/SubPanelViewer.php'; $action_file_map['save2'] = 'include/generic/Save2.php';
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Controller/index.html
8877de60358e-4
$action_file_map['deleterelationship'] = 'include/generic/DeleteRelationship.php'; $action_file_map['import'] = 'modules/Import/index.php'; Here the developer has the opportunity to map an action to a file. For example, Sugar uses a generic sub-panel file for handling subpanel actions. You can see above that there is an entry mapping the action 'subpanelviewer' to ./include/SubPanel/SubPanelViewer.php. The base SugarController class loads the action mappings in the following path sequence: ./include/MVC/Controller ./modules/<module> ./custom/modules/<module> ./custom/include/MVC/Controller
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Controller/index.html
8877de60358e-5
./custom/modules/<module> ./custom/include/MVC/Controller Each one loads and overrides the previous definition if in conflict. You can drop a new action_file_map in the later path sequence that extends or overrides the mappings defined in the previous one. Upgrade-Safe Implementation If you want to add custom action_file_map.php to an existing module that came with the SugarCRM release, you should place the file at ./custom/modules/<module>/action_file_map.php File Structure ./include/MVC/Controller/action_file_map.php ./modules/<module>/action_file_map.php ./custom/modules/<module>/action_file_map.php Implementation $action_file_map['soapRetrieve'] = 'custom/SoapRetrieve/soap.php';
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Controller/index.html
8877de60358e-6
Classic Support (Not Recommended) Classic support allows you to have files that represent actions within your module. Essentially, you can drop in a PHP file into your module and have that be handled as an action. This is not recommended, but is considered acceptable for backward compatibility. The better practice is to take advantage of the action_<action> structure. File Structure ./modules/<module>/<action>.php Controller Flow Overview For example, if a request comes in for DetailView the controller will handle the request as follows: Start in index.php and load the SugarApplication instance. SugarApplication instantiates the SugarControllerFactory. SugarControllerFactory loads the appropriate Controller. SugarControllerFactory checks for ./custom/modules/<module>/Controller.php. If not found, check for ./modules/<module>/Controller.php. If not found, load SugarController.php.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Controller/index.html
8877de60358e-7
If not found, load SugarController.php. Calls on the appropriate action. Look for ./custom/modules/<module>/<action>.php. If found and ./custom/modules/<module>/views/view.<action>.php is not found, use this view. If not found check for modules/<module>/<action>.php. If found and ./modules/<module>/views/view.<action>.php is not found, then use the ./modules/<module>/<action>.php action. If not found, check for the method action_<action> in the controller. If not found, check for an action_file_mapping. If not found, report error "Action is not defined". Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Controller/index.html
f400b94c6dbe-0
Examples Provides an overview of example MVC customizations.  TopicsChanging the ListView Default Sort OrderThis article addresses the need to customize the advanced search layout options for modules in backward compatibility mode to change the default sort order from ascending to descending. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Examples/index.html
0896b94bdd7c-0
Changing the ListView Default Sort Order Overview This article addresses the need to customize the advanced search layout options for modules in backward compatibility mode to change the default sort order from ascending to descending. Customization Information This customization is only for modules in backward compatibility mode and involves creating custom files that extend stock files. You should note that this customization does not address all scenarios within the view that may assign a sort order. Extending the Search Form First, we will need to extend the SearchForm class. To do this, we will create a CustomSearchForm class that extends the original SearchForm class located in ./include/SearchForm/SearchForm2.php. We will then override the _displayTabs method to check the $_REQUEST['sortOrder'] and default it to descending if it isn't set. ./custom/include/SearchForm/SearchForm2.php <?php
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Examples/Changing_the_ListView_Default_Sort_Order/index.html
0896b94bdd7c-1
./custom/include/SearchForm/SearchForm2.php <?php require_once 'include/SearchForm/SearchForm2.php'; class CustomSearchForm extends SearchForm { /** * displays the tabs (top of the search form) * * @param string $currentKey key in $this->tabs to show as the current tab * * @return string html */ function _displayTabs($currentKey) { //check and set the default sort order if (!isset($_REQUEST['sortOrder'])) { $_REQUEST['sortOrder'] = 'DESC'; } return parent::_displayTabs($currentKey);; } } ?> Extending the List View
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Examples/Changing_the_ListView_Default_Sort_Order/index.html
0896b94bdd7c-2
} } ?> Extending the List View Next, we will need to extend the ListView. We will create a ViewCustomList class that extends the original ListView located in ./include/MVC/View/views/view.list.php. In the ViewCustomList class, we will override the prepareSearchForm and getSearchForm2 methods to call the CustomSearchForm class. ./custom/include/MVC/View/views/view.customlist.php <?php require_once 'include/MVC/View/views/view.list.php'; class ViewCustomList extends ViewList { function prepareSearchForm() { $this->searchForm = null; //search $view = 'basic_search';
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Examples/Changing_the_ListView_Default_Sort_Order/index.html
0896b94bdd7c-3
//search $view = 'basic_search'; if(!empty($_REQUEST['search_form_view']) && $_REQUEST['search_form_view'] == 'advanced_search') $view = $_REQUEST['search_form_view']; $this->headers = true; if(!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only']) $this->headers = false; elseif(!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') { if(isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') { $view = 'advanced_search'; } else
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Examples/Changing_the_ListView_Default_Sort_Order/index.html
0896b94bdd7c-4
{ $view = 'advanced_search'; } else { $view = 'basic_search'; } } $this->view = $view; $this->use_old_search = true; if (SugarAutoLoader::existingCustom('modules/' . $this->module . '/SearchForm.html') && !SugarAutoLoader::existingCustom('modules/' . $this->module . '/metadata/searchdefs.php')) { require_once('include/SearchForm/SearchForm.php'); $this->searchForm = new SearchForm($this->module, $this->seed); } else { $this->use_old_search = false; //Updated to require the extended CustomSearchForm class
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Examples/Changing_the_ListView_Default_Sort_Order/index.html
0896b94bdd7c-5
//Updated to require the extended CustomSearchForm class require_once('custom/include/SearchForm/SearchForm2.php'); $searchMetaData = SearchForm::retrieveSearchDefs($this->module); $this->searchForm = $this->getSearchForm2($this->seed, $this->module, $this->action); $this->searchForm->setup($searchMetaData['searchdefs'], $searchMetaData['searchFields'], 'SearchFormGeneric.tpl', $view, $this->listViewDefs); $this->searchForm->lv = $this->lv; } } /** * Returns the search form object * * @return SearchForm */ protected function getSearchForm2($seed, $module, $action = "index") {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Examples/Changing_the_ListView_Default_Sort_Order/index.html
0896b94bdd7c-6
{ //Updated to use the extended CustomSearchForm class return new CustomSearchForm($seed, $module, $action); } } ?> Extending the Sugar Controller Finally, we will create a CustomSugarController class that extends the orginal SugarController located in ./include/MVC/Controller/SugarController.php. We will then need to override the do_action and post_action methods to execute their parent methods as well as the action_listview method to assign the custom view to the view attribute. ./custom/include/MVC/Controller/SugarController.php <?php /** * Custom SugarCRM controller * @api */ class CustomSugarController extends SugarController { /** * Perform the specified action. * This can be overridde in a sub-class */ private function do_action()
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Examples/Changing_the_ListView_Default_Sort_Order/index.html
0896b94bdd7c-7
*/ private function do_action() { return parent::do_action(); } /** * Perform an action after to the specified action has occurred. * This can be overridde in a sub-class */ private function post_action() { return parent::post_action(); } /** * Perform the listview action */ protected function action_listview() { parent::action_listview(); //set the new custom view $this->view = 'customlist'; } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Examples/Changing_the_ListView_Default_Sort_Order/index.html
09164d825bbf-0
Metadata Overview An overview of the legacy MVC metadata framework. You should note that the MVC architecture is being deprecated and is being replaced with sidecar. Until the framework is fully deprecated, modules set in backward compatibility mode will still use the legacy MVC framework. Metadata Framework Background Metadata is defined as information about data. In Sugar, metadata refers to the framework of using files to abstract the presentation and business logic found in the system. The metadata framework is described in definition files that are processed using PHP. The processing usually includes the use of Smarty templates for rendering the presentation and JavaScript libraries to handle some business logic that affects conditional displays, input validation, and so on. Application Metadata All application modules are defined in the modules.php file. It contains several variables that define which modules are active and usable in the application.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-1
The file is located under the '<sugar root>/include' folder. It contains the $moduleList() array variable which contains the reference to the array key to look up the string to be used to display the module in the tabs at the top of the application. The coding standard is for the value to be in the plural of the module name; for example, Contacts, Accounts, Widgets, and so on. The $beanList() array stores a list of all active beans (modules) in the application. The $beanList entries are stored in a 'name' => 'value' fashion with the 'name' value being in the plural and the 'value' being in the singular of the module name. The 'value' of a $beanList() entry is used to lookup values in our next modules.php variable, the $beanFiles() array.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-2
The $beanFiles variable is also stored in a 'name' => 'value' fashion. The 'name', typically in singular, is a reference to the class name of the object, which is looked up from the $beanList 'value', and the 'value' is a reference to the class file. The remaining relevant variables in the modules.php file are the $modInvisList variable which makes modules invisible in the regular user interface (i.e., no tab appears for these modules), and the $adminOnlyList which is an extra level of security for modules that are accessible only by administrators through the Admin page. Module Metadata The following table lists the metadata definition files found in the modules/[module]/metadata directory, and a brief description of their purpose within the system. File Description additionalDetails.php Used to render the popup information displayed when a user hovers the mouse cursor over a row in the List View.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-3
editviewdefs.php Used to render a record's EditView. detailviewdefs.php Used to render a record's DetailView. listviewdefs.php Used to render the List View display for a module. metafiles.php Used to override the location of the metadata definition file to be used. The EditView, DetailView, List View, and Popup code check for the presence of these files. popupdefs.php Used to render and handle the search form and list view in popups. searchdefs.php Used to render a module's basic and advanced search form displays. sidecreateviewdefs.php Used to render a module's quick create form shown in the side shortcut panel. subpaneldefs.php Used to render a module's subpanels shown when viewing a record's DetailView. SearchForm Metadata
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-4
SearchForm Metadata The search form layout for each module is defined in the module's metadata file searchdefs.php. A sample of the Accounts searchdefs.php appears as: <?php $searchdefs['Accounts'] = array( 'templateMeta' => array( 'maxColumns' => '3', 'widths' => array( 'label' => '10', 'field' => '30' ) ), 'layout' => array( 'basic_search' => array( 'name', 'billing_address_city', 'phone_office', array( 'name' => 'address_street', 'label' => 'LBL_BILLING_ADDRESS', 'type' => 'name',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-5
'type' => 'name', 'group' => 'billing_address_street' ), array( 'name' => 'current_user_only', 'label' => 'LBL_CURRENT_USER_FILTER', 'type'=>'bool' ), ), 'advanced_search' => array( 'name', array( 'name' => 'address_street', 'label' => 'LBL_ANY_ADDRESS', 'type' => 'name' ), array( 'name' => 'phone', 'label' => 'LBL_ANY_PHONE', 'type' => 'name' ), 'website', array( 'name' => 'address_city',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-6
array( 'name' => 'address_city', 'label' => 'LBL_CITY', 'type' => 'name' ), array( 'name' => 'email', 'label' =>'LBL_ANY_EMAIL', 'type' => 'name' ), 'annual_revenue', array( 'name' => 'address_state', 'label' =>'LBL_STATE', 'type' => 'name' ), 'employees', array( 'name' => 'address_postalcode', 'label' =>'LBL_POSTAL_CODE', 'type' => 'name' ), array(
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-7
'type' => 'name' ), array( 'name' => 'billing_address_country', 'label' =>'LBL_COUNTRY', 'type' => 'name' ), 'ticker_symbol', 'sic_code', 'rating', 'ownership', array( 'name' => 'assigned_user_id', 'type' => 'enum', 'label' => 'LBL_ASSIGNED_TO', 'function' => array( 'name' =>'get_user_array', 'params' => array(false) ) ), 'account_type', 'industry', ), ), ); ?>
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-8
'industry', ), ), ); ?> The searchdefs.php file contains the Array variable $searchDefs with one entry. The key is the name of the module as defined in $moduleList array defined in include/modules.php. The $searchDefsarray is another array that describes the search form layout and fields. The 'templateMeta' key points to another array that controls the maximum number of columns in each row of the search form ('maxColumns'), as well as layout spacing attributes as defined by 'widths'. In the above example, the generated search form files will allocate 10% of the width spacing to the labels and 30% for each field respectively.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-9
The 'layout' key points to another nested array which defines the fields to display in the basic and advanced search form tabs. Each individual field definition maps to a SugarField widget. See the SugarField widget section for an explanation about SugarField widgets and how they are rendered for the search form, DetailView, and EditView.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-10
The searchdefs.php file is invoked from the MVC framework whenever a module's list view is rendered (see include/MVC/View/views/view.list.php). Within view.list.php, checks are made to see if the module has defined a SearchForm.html file. If this file exists, the MVC will run in classic mode and use the aforementioned include/SearchForm/SearchForm.php file to process the search form. Otherwise, the new search form processing is invoked using include/SearchForm/SearchForm2.php and the searchdefs.php file is scanned for, first under the custom/modules/[module]/metadata directory and then in modules/[module]/metadata. The processing flow for the search form using the metadata subpaneldefs.php file is similar to that of EdiView and DetailView. DetailView and EditView Metadata
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-11
DetailView and EditView Metadata Metadata files are PHP files that declare nested Array values that contain information about the view, such as buttons, hidden values, field layouts, and more. Following is a visual diagram representing how the Array values declared in the Metadata file are nested: The following diagram highlights the process of how the application determines which Metadata file is to be used when rendering a request for a view: The "Classic Mode" on the right hand side of the diagram represents the SugarCRM pre-5.x rendering of a Detail/Editview. This section will focus on the MVC/Metadata mode.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-12
When the view is first requested, the preDisplay method will attempt to find the correct Metadata file to use. Typically, the Metadata file will exist in the [root level]/modules/[module]/metadata directory, but in the event of edits to a layout through the Studio interface, a new Metadata file will be created and placed in the [root level]/custom/modules/[module]/metadata directory. This is done so that changes to layouts may be restored to their original state through Studio, and also to allow changes made to layouts to be upgrade-safe when new patches and upgrades are applied to the application. The metafiles.php file that may be loaded allows for the loading of Metadata files with alternate naming conventions or locations. An example of the metafiles.php contents can be found for the Accounts module (though it is not used by default in the application). $metafiles['Accounts'] = array(
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-13
$metafiles['Accounts'] = array( 'detailviewdefs' => 'modules/Accounts/metadata/detailviewdefs.php', 'editviewdefs' => 'modules/Accounts/metadata/editviewdefs.php', 'ListViewdefs' => 'modules/Accounts/metadata/ListViewdefs.php', 'searchdefs' => 'modules/Accounts/metadata/searchdefs.php', 'popupdefs' => 'modules/Accounts/metadata/popupdefs.php', 'searchfields' => 'modules/Accounts/metadata/SearchFields.php', );
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-14
); After the Metadata file is loaded, the preDisplay method also creates an EditView object and checks if a Smarty template file needs to be built for the given Metadata file. The EditView object does the bulk of the processing for a given Metadata file (creating the template, setting values, setting field level ACL controls if applicable, etc.). Please see the EditView process diagram for more detailed information about these steps. After the preDisplay method is called in the view code, the display method is called, resulting in a call to the EditView object's process method, as well as the EditView object's display method. The EditView class is responsible for the bulk of the Metadata file processing and creation of the resulting display. The EditView class also checks to see if the resulting Smarty template is already created. It also applies the field level ACL controls for Sugar Sell, Serve, Ultimate, Enterprise, Corporate, and Professional.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-15
The classes responsible for displaying the Detail View and SearchForm also extend and use the EditView class. The ViewEdit, ViewDetail and ViewSidequickcreate classes use the EditView class to process and display their contents. Even the file that renders the quick create form display (SubpanelQuickCreate.php) uses the EditView class. DetailView (in DetailView2.php) and SearchForm (in SearchForm2.php) extend the EditView class while SubpanelQuickCreate.php uses an instance of the EditView class. The following diagram highlights these relationships. The following diagram highlights the EditView class's main responsibilities and their relationships with other classes in the system. We will use the example of a DetailView request although the sequence will be similar for other views that use the EditView class.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-16
One thing to note is the EditView class's interaction with the TemplateHandler class. The TemplateHandler class is responsible for generating a Smarty template in the cache/modules/<module> directory. For example, for the Accounts module, the TemplateHandler will create the Smarty file, cache/modules/Accounts/DetailView.tpl, based on the Metadata file definition and other supplementary information from the EditView class. The TemplateHandler class actually uses Smarty itself to generate the resulting template that is placed in the aforementioned cache directory.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-17
Some of the modules that are available in the SugarCRM application also extend the ViewDetail class. One example of this is the DetailView for the Projects module. As mentioned in the MVC section, it is possible to extend the view classes by placing a file in the modules/<module>/views directory. In this case, a view.detail.php file exists in the modules/Projects/views folder. This may serve as a useful example in studying how to extend a view and apply additional field/layout settings not provided by the EditView class. The following diagram shows the files involved with the DetailView example in more detail: A high level processing summary of the components for DetailViews follows: The MVC framework receives a request to process the DetaiView.php (A) action for a module. For example, a record is selected from the list view shown on the browser with URL:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-18
index.php?action=DetailView&module=Opportunities&record=46af9843-ccdf-f489-8833
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-19
At this point the new MVC framework checks to see if there is a DetailView.php (A2) file in the modules/Opportunity directory that will override the default DetailView.php implementation. The presence of a DetailView.php file will trigger the "classic" MVC view. If there is no DetailView.php (A2) file in the directory, the MVC will also check if you have defined a custom view to handle the DetailView rendering in MVC (that is, checks if there is a file modules/Opportunity/views/view.detail.php). See the documentation for the MVC architecture for more information. Finally, if neither the DetailView.php (A2) nor the view.detail.php exists, then the MVC will invoke include/DetailView/DetailView.php (A).
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-20
The MVC framework (see views.detail.php in include/MVC/View/views folder) creates an instance of the generic DetailView (A) // Call DetailView2 constructor $dv = new DetailView2(); // Assign by reference the Sugar_Smarty object created from MVC // We have to explicitly assign by reference to back support PHP 4.x $dv->ss =& $this->ss; // Call the setup function $dv->setup($this->module, $this->bean, $metadataFile, 'include/DetailView/DetailView.tpl'); // Process this view $dv->process(); // Return contents to the buffer echo $dv->display();
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-21
echo $dv->display(); When the setup method is invoked, a TemplateHandler instance (D) is created. A check is performed to determine which detailviewdefs.php metadata file to used in creating the resulting DetailView. The first check is performed to see if a metadata file was passed in as a parameter. The second check is performed against the custom/studio/modules/[Module] directory to see if a metadata file exists. For the final option, the DetailView constructor will use the module's default detailviewdefs.php metadata file located under the modules/[Module]/metadata directory. If there is no detailviewdefs.php file in the modules/[Module]/metadata directory, but a DetailView.html exists, then a "best guess" version is created using the metadata parser file in include/SugarFields/Parsers/DetailViewMetaParser.php (not shown in diagram).
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-22
The TemplateHandler also handles creating the quick search (Ajax code to do look ahead typing) as well as generating the JavaScript validation rules for the module. Both the quick search and JavaScript code should remain static based on the definitions of the current definition of the metadata file. When fields are added or removed from the file through Studio, this template and the resulting updated quick search and JavaScript code will be rebuilt. It should be noted that the generic DetailView (A) defaults to using the generic DetailView.tpl smarty template file (F). This may also be overridden through the constructor parameters. The generic DetailView (A) constructor also retrieves the record according to the record id and populates the $focus bean variable. The process() method is invoked on the generic DetailView.php instance: function process() { //Format fields first if($this->formatFields) {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-23
//Format fields first if($this->formatFields) { $this->focus->format_all_fields(); } parent::process(); } This, in turn, calls the EditView->process() method since DetailView extends from EditView. The EditView->process() method will eventually call the EditView->render() method to calculate the width spacing for the DetailView labels and values. The number of columns and the percentage of width to allocate to each column may be defined in the metadata file. The actual values are rounded as a total percentage of 100%. For example, given the templateMeta section's maxColumns and widths values: 'templateMeta' => array( 'maxColumns' => '2', 'widths' => array( array( 'label' => '10', 'field' => '30'
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-24
'label' => '10', 'field' => '30' ), array( 'label' => '10', 'field' => '30' ) ), ), We can see that the labels and fields are mapped as a 1-to-3 ratio. The sum of the widths only equals a total of 80 (10 + 30 x 2) so the actual resulting values written to the Smarty template will be at a percentage ratio of 12.5-to-37.5. The resulting fields defined in the metadata file will be rendered as a table with the column widths as defined: The actual metadata layout will allow for variable column lengths throughout the displayed table. For example, the metadata portion defined as: 'panels' => array( 'default' => array( array( 'name', array(
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-25
array( 'name', array( 'name' => 'amount', 'label' => '{$MOD.LBL_AMOUNT} ({$CURRENCY})', ), ), array( 'account_name', ), array( '', 'opportunity_type', ) ) ) This specifies a default panel under the panels section with three rows. The first row has two fields (name and amount). The amount field has some special formatting using the label override option. The second row contains the account_name field and the third row contains the opportunity_type column.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-26
Next, the process() method populates the $fieldDefs array variable with the vardefs.php file (G) definition and the $focus bean's value. This is done by calling the toArray () method on the $focus bean instance and combining these values with the field definition specified in the vardefs.php file (G). The display() method is then invoked on the generic DetailView instance for the final step. When the display() method is invoked, variables to the DetailView.tpl Smarty template are assigned and the module's HTML code is sent to the output buffer.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-27
Before HTML code is sent back, the TemplateHandler (D) first performs a check to see if an existing DetailView template already exists in the cache respository (H). In this case, it will look for file cache/modules/Opportunity/DetailView.tpl. The operation of creating the Smarty template is expensive so this operation ensures that the work will not have to be redone. As a side note, edits made to the DetailView or EditView through the Studio application will clear the cache file and force the template to be rewritten so that the new changes are reflected. If the cache file does not exist, the TemplateHandler (D) will create the template file and store it in the cache directory. When the fetch() method is invoked on the Sugar_Smarty class (E) to create the template, the DetailView.tpl file is parsed. TopicsExamplesLegacy MVC metadata examples.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
09164d825bbf-28
TopicsExamplesLegacy MVC metadata examples. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/index.html
2ac2a676f2d8-0
Examples Legacy MVC metadata examples. TopicsHiding the Quotes Module PDF ButtonsHow to hide the PDF buttons on a Quote.Manipulating Buttons on Legacy MVC LayoutsHow to add custom buttons to the EditView and DetailView layouts.Manipulating Layouts ProgrammaticallyHow to manipulate and merge layouts programmatically.Modifying Layouts to Display Additional ColumnsHow to add additional columns to layouts. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/index.html
6a55ee9d3627-0
Manipulating Layouts Programmatically Overview How to manipulate and merge layouts programmatically. Note: This customization is only applicable for modules in backward compatibility mode. The ParserFactory The ParserFactory can be used to manipulate layouts such as editviewdefs or detailviewdefs. This is a handy when creating custom plugins and needing to merge changes into an existing layout. The following example will demonstrate how to add a button to the detail view: <?php //Instantiate the parser factory for the Accounts DetailView. require_once('modules/ModuleBuilder/parsers/ParserFactory.php'); $parser = ParserFactory::getParser('detailview', 'Accounts'); //Button to add $button = array( 'customCode'=>'<input type="button" name="customButton" value="Custom Button">' ); //Add button into the parsed layout
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Manipulating_Layouts_Programmatically/index.html
6a55ee9d3627-1
); //Add button into the parsed layout array_push($parser->_viewdefs['templateMeta']['form']['buttons'], $button); //Save the layout $parser->handleSave(false);   Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Manipulating_Layouts_Programmatically/index.html
f9b0e89ff701-0
Modifying Layouts to Display Additional Columns Overview How to add additional columns to layouts. By default, the editview, detailview, and quickcreate layouts for each module display two columns of fields. The number of columns to display can be customized on a per-module basis with the following steps. Note: This customization is only applicable for modules in backward compatibility mode. Resolution SugarCloud
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Modifying_Layouts_to_Display_Additional_Columns/index.html
f9b0e89ff701-1
Resolution SugarCloud First, you will want to ensure your layouts are deployed in the custom directory. If you have not previously customized your layouts via Studio, go to Admin > Studio > {Module Name} > Layouts. From there, select each layout you wish to add additional columns to and click 'Save & Deploy'. This action will create a corresponding layout file under the ./custom/modules/{Module Name}/metadata/ directory. The files will be named editviewdefs.php, detailviewdefs.php, and quickcreatedefs.php depending on the layouts deployed.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Modifying_Layouts_to_Display_Additional_Columns/index.html
f9b0e89ff701-2
To access your custom files, go to Admin > Diagnostic Tool, uncheck all the boxes except for "SugarCRM Custom directory" and then click "Execute Diagnostic". This will generate an archive of your instance's custom directory to download, and you will find the layout files in the above path. Open the custom layout file, locate the 'maxColumns' value, and change it to the number of columns you would like to have on screen: 'maxColumns' => '3', Once that is updated, locate the 'widths' array to define the spacing for your new column(s). You should have a label and field entry for each column in your layout: 'widths' => array ( 0 => array ( 'label' => '10', 'field' => '30', ), 1 => array ( 'label' => '10',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Modifying_Layouts_to_Display_Additional_Columns/index.html
f9b0e89ff701-3
), 1 => array ( 'label' => '10', 'field' => '30', ), 2 => array ( 'label' => '10', 'field' => '30', ), ), After this is completed, you will need to create a module-loadable package to install the changes on your SugarCloud instance. More information on creating this package can be found in Creating an Installable Package that Creates New Fields. To upload and install the package, go to Admin > Module Loader. Note: Sugar Sell Essentials customers do not have the ability to upload custom file packages to Sugar using Module Loader.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Modifying_Layouts_to_Display_Additional_Columns/index.html
f9b0e89ff701-4
Once the installation completes, you can navigate to Studio and add fields to your new column in the layout. For any rows that already contain two fields, the second field will automatically span the second and third column. Simply click the minus (-) icon to contract the field to one column and expose the new column space: After you have added the desired fields in Studio, click 'Save & Deploy', and you are ready to go! On-Site
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Modifying_Layouts_to_Display_Additional_Columns/index.html
f9b0e89ff701-5
On-Site First, you will want to ensure your layouts are deployed in the custom directory. If you have not previously customized your layouts via Studio, go to Admin > Studio > {Module Name} > Layouts. From there, select each layout you wish to add additional columns to and click 'Save & Deploy'. This action will create a corresponding layout file under the ./custom/modules/{Module Name}/metadata/ directory. The files will be named editviewdefs.php, detailviewdefs.php, and quickcreatedefs.php depending on the layouts deployed. Next, open the custom layout file, locate the 'maxColumns' value, and change it to the number of columns you would like to have on screen: 'maxColumns' => '3',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Modifying_Layouts_to_Display_Additional_Columns/index.html
f9b0e89ff701-6
'maxColumns' => '3', Once that is updated, locate the 'widths' array to define the spacing for your new column(s). You should have a label and field entry for each column in your layout: 'widths' => array ( 0 => array ( 'label' => '10', 'field' => '30', ), 1 => array ( 'label' => '10', 'field' => '30', ), 2 => array ( 'label' => '10', 'field' => '30', ), ),
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Modifying_Layouts_to_Display_Additional_Columns/index.html
f9b0e89ff701-7
'field' => '30', ), ), Once this is completed, you can navigate to Studio and add fields to your new column in the layout. For any rows that already contain two fields, the second field will automatically span the second and third column. Simply click the minus (-) icon to contract the field to one column and expose the new column space: After you have added the desired fields in Studio, click 'Save & Deploy', and you are ready to go! Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Modifying_Layouts_to_Display_Additional_Columns/index.html
4204db6fa027-0
Hiding the Quotes Module PDF Buttons Overview How to hide the PDF buttons on a Quote. The PDF buttons on quotes are rendered differently than the standard buttons on most layouts. Since these buttons can't be removed directly from the DetailView in the detailviewdefs, the best approach is using jQuery to hide the buttons. Note: This customization is only applicable for the quotes module as it is in backward compatibility mode. Hidding the PDF Buttons This approach involves modifying the detailviewdefs.php in the custom/modules/Quotes/metadata directory to include a custom JavaScript file. If a custom detailviewdefs.php file doesn't exist, you will need to create it through Studio or by manually coping the detailviewdefs.php from the Quotes stock module metadata directory.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Hidding_the_Quotes_Module_PDF_Buttons/index.html
4204db6fa027-1
coping the detailviewdefs.php from the Quotes stock module metadata directory. First, we will create a javascript file, say removePdfBtns.js, in the ./custom/modules/Quotes directory. This javascript file will contain the jQuery statements to hide the Quotes "Download PDF" and "Email PDF" buttons on the DetailView of the Quote. ./custom/modules/Quotes/removePdfBtns.js SUGAR.util.doWhen("typeof $ != 'undefined'", function(){ YAHOO.util.Event.onDOMReady(function(){ $("#pdfview_button").hide(); $("#pdfemail_button").hide(); }); }); Next, we will modify the custom detailviewdefs.php file to contain the 'includes' array element in the templateMeta array as follows:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Hidding_the_Quotes_Module_PDF_Buttons/index.html
4204db6fa027-2
./custom/modules/Quotes/metadata/detailviewdefs.php $viewdefs['Quotes'] = array ( 'DetailView' => array ( 'templateMeta' => array ( 'form' => array ( 'closeFormBeforeCustomButtons' => true, 'buttons' => array ( 0 => 'EDIT', 1 => 'SHARE', 2 => 'DUPLICATE', 3 => 'DELETE', 4 => array ( 'customCode' => '<form action="index.php" method="POST" name="Quote2Opp" id="form"> <input type="hidden" name="module" value="Quotes"> <input type="hidden" name="record" value="{$fields.id.value}">
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Hidding_the_Quotes_Module_PDF_Buttons/index.html
4204db6fa027-3
<input type="hidden" name="user_id" value="{$current_user->id}"> <input type="hidden" name="team_id" value="{$fields.team_id.value}"> <input type="hidden" name="user_name" value="{$current_user->user_name}"> <input type="hidden" name="action" value="QuoteToOpportunity"> <input type="hidden" name="opportunity_subject" value="{$fields.name.value}"> <input type="hidden" name="opportunity_name" value="{$fields.name.value}"> <input type="hidden" name="opportunity_id" value="{$fields.billing_account_id.value}">
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Hidding_the_Quotes_Module_PDF_Buttons/index.html
4204db6fa027-4
<input type="hidden" name="amount" value="{$fields.total.value}"> <input type="hidden" name="valid_until" value="{$fields.date_quote_expected_closed.value}"> <input type="hidden" name="currency_id" value="{$fields.currency_id.value}"> <input id="create_opp_from_quote_button" title="{$APP.LBL_QUOTE_TO_OPPORTUNITY_TITLE}" class="button" type="submit" name="opp_to_quote_button" value="{$APP.LBL_QUOTE_TO_OPPORTUNITY_LABEL}" {$DISABLE_CONVERT}></form>', ), ),
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Hidding_the_Quotes_Module_PDF_Buttons/index.html
4204db6fa027-5
), ), 'footerTpl' => 'modules/Quotes/tpls/DetailViewFooter.tpl', ), 'maxColumns' => '2', 'widths' => array ( 0 => array ( 'label' => '10', 'field' => '30', ), 1 => array ( 'label' => '10', 'field' => '30', ), ), 'includes' => array ( 0 => array ( 'file' => 'custom/modules/Quotes/removePdfBtns.js', ), ), 'useTabs' => false, 'tabDefs' => array ( 'LBL_QUOTE_INFORMATION' =>
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Hidding_the_Quotes_Module_PDF_Buttons/index.html
4204db6fa027-6
array ( 'LBL_QUOTE_INFORMATION' => array ( 'newTab' => false, 'panelDefault' => 'expanded', ), 'LBL_PANEL_ASSIGNMENT' => array ( 'newTab' => false, 'panelDefault' => 'expanded', ), ), ), ... Finally, navigate to: Admin > Repair > Quick Repair and Rebuild The buttons will then be removed from the DetailView layouts. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Hidding_the_Quotes_Module_PDF_Buttons/index.html
dbaddf9e1387-0
Manipulating Buttons on Legacy MVC Layouts Overview How to add custom buttons to the EditView and DetailView layouts. Note: This customization is only applicable for modules in backward compatibility mode. Metadata Before adding buttons to your layouts, you will need to understand how the metadata framework is used. Detailed information on the metadata framework can be found in the Legacy Metadata section. Custom Layouts Before you can add a button to your layout, you will first need to make sure you have a custom layout present. The stock layouts are located in ./modules/<module>/metadata/ and must be recreated in ./custom/modules/<module>/metadata/. There are two ways to recreate a layout in the custom directory if it does not already exist. The first is to navigate to: Studio > {Module} > Layouts > {View}
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Manipulating_Buttons_on_Layouts/index.html
dbaddf9e1387-1
Studio > {Module} > Layouts > {View} Once there, you can click the "Save & Deploy" button. This will create the layoutdef for you. Alternatively, you can also manually copy the layoutdef from the stock folder to the custom folder. Editing Layouts When editing layouts you have three options in having your changes reflected in the UI. Developer Mode You can turn on Developer Mode: Admin > System Settings Developer Mode will remove the caching of the metadata framework. This will cause your changes to be reflected when the page is refreshed. Make sure this setting is deactivated when you are finished with your customization. Quick Repair and Rebuild You can run a Quick Repair and Rebuild: Admin > Repair > Quick Repair and Rebuild Doing this will rebuild the cache for the metadata. Saving & Deploying the Layout in Studio
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Manipulating_Buttons_on_Layouts/index.html
dbaddf9e1387-2
Saving & Deploying the Layout in Studio You may also choose to load the layout in studio and then save & deploy it: Admin > Studio > {Module} > Layouts > {View} This process can be a bit confusing, however, once a layout is changed, you can then choose to load the layout in studio and then click "Save & Deploy" . This will rebuild the cache for that specific layout. Please note that any time you change the layout, you will have to reload the Studio layout view before deploying in order for this to work correctly. Adding Custom Buttons When adding buttons, there are several things to consider when determining how the button should be rendered. The following sections will outline these scenarios when working with the accounts editviewdefs located in ./custom/modules/Accounts/metadata/editviewdefs.php. JavaScript Actions
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Manipulating_Buttons_on_Layouts/index.html
dbaddf9e1387-3
JavaScript Actions If you are adding a button solely to execute JavaScript (no form submissions), you can do so by adding the button HTML to: $viewdefs['<Module>']['<View>']['templateMeta']['form']['buttons'] Example <?php $viewdefs['Accounts'] = array ( 'DetailView' => array ( 'templateMeta' => array ( 'form' => array ( 'buttons' => array ( 0 => 'EDIT', 1 => 'DUPLICATE', 2 => 'DELETE', 3 => 'FIND_DUPLICATES', 4 => 'CONNECTOR', 5 => array (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Manipulating_Buttons_on_Layouts/index.html
dbaddf9e1387-4
4 => 'CONNECTOR', 5 => array ( 'customCode' => '<input id="JavaScriptButton" title="JavaScript Button" class="button" type="button" name="JavaScriptButton" value="JavaScript Button" onclick="alert(\'Button JavaScript\')">', ), ), ), Submitting the Stock View Form If you intend to submit the stock layout form ('formDetailView' or 'formEditView') to a new action, you can do so by adding a the button HTML with an onclick event as shown below to: $viewdefs['<Module>']['<View>']['templateMeta']['form']['buttons'] Example <?php $viewdefs['Accounts'] = array ( 'DetailView' => array (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Manipulating_Buttons_on_Layouts/index.html
dbaddf9e1387-5
array ( 'DetailView' => array ( 'templateMeta' => array ( 'form' => array ( 'hidden' => array ( 0 => '<input type="hidden" id="customFormField" name="customFormField" value="">', ), 'buttons' => array ( 0 => 'EDIT', 1 => 'DUPLICATE', 2 => 'DELETE', 3 => 'FIND_DUPLICATES', 4 => 'CONNECTOR', 5 => array (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Manipulating_Buttons_on_Layouts/index.html
dbaddf9e1387-6
4 => 'CONNECTOR', 5 => array ( 'customCode' => '<input id="SubmitStockFormButton" title="Submit Stock Form Button" class="button" type="button" name="SubmitStockFormButton" value="Submit Stock Form Button" onclick="var _form = document.getElementById(\'formDetailView\'); _form.customFormField.value = \'CustomValue\'; _form.action.value = \'CustomAction\'; SUGAR.ajaxUI.submitForm(_form);">', ), ), ), You should note in this example that there is also a 'hidden' index. This is where you should add any custom hidden inputs: $viewdefs['<Module>'][ '<View>'][ 'templateMeta'][ 'form'][ 'hidden']
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Manipulating_Buttons_on_Layouts/index.html
dbaddf9e1387-7
'templateMeta'][ 'form'][ 'hidden'] Submitting Custom Forms If you intend to submit a custom form, you will first need to set 'closeFormBeforeCustomButtons' to true. This will close out the current views form and allow you to create your own. $viewdefs['<Module>']['<View>']['templateMeta']['form']['closeFormBeforeCustomButtons'] Next, you will add the form and button HTML as shown below to: $viewdefs['<Module>']['<View>']['templateMeta']['form']['buttons'] Example <?php $viewdefs['Accounts'] = array ( 'DetailView' => array ( 'templateMeta' => array ( 'form' => array (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Manipulating_Buttons_on_Layouts/index.html
dbaddf9e1387-8
array ( 'form' => array ( 'closeFormBeforeCustomButtons' => true, 'buttons' => array ( 0 => 'EDIT', 1 => 'DUPLICATE', 2 => 'DELETE', 3 => 'FIND_DUPLICATES', 4 => 'CONNECTOR', 5 => array ( 'customCode' => '<form action="index.php" method="POST" name="CustomForm" id="form"><input type="hidden" name="customFormField" name="customFormField" value="CustomValue"><input id="SubmitCustomFormButton" title="Submit Custom Form Button" class="button" type="submit" name="SubmitCustomFormButton" value="Submit Custom Form Button"></form>', ), ), ), Removing Buttons
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Manipulating_Buttons_on_Layouts/index.html
dbaddf9e1387-9
), ), ), Removing Buttons To remove a button from the detail view will require modifying the ./modules/<module>/metadata/detailviewdefs.php. The code is originally defined as: $viewdefs[$module_name] = array ( 'DetailView' => array ( 'templateMeta' => array ( 'form' => array ( 'buttons' => array ( 'EDIT', 'DUPLICATE', 'DELETE', 'FIND_DUPLICATES' ), ), To remove one or more buttons, simply remove the 'buttons' attribute(s) that you do not want on the view. $viewdefs[$module_name] = array ( 'DetailView' => array ( 'templateMeta' => array (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Manipulating_Buttons_on_Layouts/index.html
dbaddf9e1387-10
'DetailView' => array ( 'templateMeta' => array ( 'form' => array ( 'buttons' => array ( 'DELETE', ), ),   Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/Metadata/Examples/Manipulating_Buttons_on_Layouts/index.html
6769d7b65ab0-0
View Overview Displaying information to the browser. What are Views? Views, otherwise known as actions, are typically used to render views or to process logic. Views are not just limited to HTML data. You can send JSON encoded data as part of a view or any other structure you wish. As with the controllers, there is a default class called SugarView which implements much of the basic logic for views, such as handling of headers and footers. There are five main actions for a module: Display Actions
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/View/index.html
6769d7b65ab0-1
There are five main actions for a module: Display Actions Detail View: A detail view displays a read-only view of a particular record. Usually, this is accessed via the list view. The detail view displays the details of the object itself and related items (subpanels). Subpanels are miniature list views of items that are related to the parent object. For example, Tasks assigned to a Project, or Contacts for an Opportunity will appear in subpanels in the Project or Opportunity detail view. The file ./<module>/metadata/detailviewdefs.php defines a module's detail view page layout. The file ./<module>/metadata/subpaneldefs.php defines the subpanels that are displayed in the module's detail view page.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/View/index.html
6769d7b65ab0-2
Edit View: The edit view page is accessed when a user creates a new record or edits details of an existing one. Edit view can also be accessed directly from the list view. The file ./<module>/metadata/editviewdefs.php defines a module's edit view page layout. List View: This Controller action enables the search form and search results for a module. Users can perform actions such as delete, export, update multiple records (mass update), and drill into a specific record to view and edit the details. Users can see this view by default when they click one of the module tabs at the top of the page. Files in each module describe the contents of the list and search view. Process Actions Save: This Controller action is processed when the user clicks Save in the record's edit view.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/View/index.html
6769d7b65ab0-3
Save: This Controller action is processed when the user clicks Save in the record's edit view. Delete: This action is processed when the user clicks "Delete" in the detail view of a record or in the detail view of a record listed in a subpanel. Implementation Class File Structure ./include/MVC/Views/SugarView.php ./include/MVC/Views/view.<view>.php ./custom/include/MVC/Views/view.<view>.php ./modules/<module>/views/view.<view>.php ./custom/modules/<module>/views/view.<view>.php Class Loading The ViewFactory class loads the view based off the the following sequence loading the first file it finds: ./custom/modules/<module>/views/view.<view>.php ./modules/<module>/views/view.<view>.php
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/View/index.html
6769d7b65ab0-4
./modules/<module>/views/view.<view>.php ./custom/include/MVC/View/view.<view>.php ./include/MVC/Views/view.<view>.php Methods There are two main methods to override within a view: preDisplay(): This performs pre-processing within a view. This method is relevant only for extending existing views. For example, the include/MVC/View/views/view.edit.php file uses it, and enables developers who wishes to extend this view to leverage all of the logic done in preDisplay() and either override the display() method completely or within your own display() method call parent::display(). display(): This method displays the data to the screen. Place the logic to display output to the screen here. Creating Views
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/View/index.html
6769d7b65ab0-5
Creating Views Creating a new/view action consists of a controller action and a view file. The first step is to define your controller action. If the module does not contain a controller.php file in ./modules/<module>/ you will create the following file: ./custom/modules/<module>/controller.php <?php class <module>Controller extends SugarController { function action_MyView() { $this->view = 'myview'; } } More information on controllers can be found in the Controller section. The next step is to define your view file. This example extends the ViewDetail class but you can extend any of the classes you choose in ./include/MVC/View/views/. ./custom/modules/<module>/views/view.newview.php <?php
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/View/index.html
6769d7b65ab0-6
<?php require_once 'include/MVC/View/views/view.detail.php' ; class <module>ViewMyView extends ViewDetail { function display() { echo 'This is my new view<br>'; } } Overriding Views The following section will demonstrate how to extend and override a view. When overriding existing actions and views, you won't need to make any changes to the controller. This approach will be very similar for any view you may choose to modify. If the module you are extending the view for does not contain an existing view in its modules views directory ( ./modules/<module>/views/ ), you will need to extend the views base class. Otherwise, you will extend the view class found within the file.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/View/index.html
6769d7b65ab0-7
In the case of a detail view, you would check for the file ./modules/<module>/views/view.detail.php. If this file does not exist, you will create ./custom/modules/<module>/views/view.detail.php and extend the base ViewDetail class with the name <module>ViewDetail. ./custom/modules/<module>/views/view.detail.php <?php require_once('include/MVC/View/views/view.detail.php'); class <module>ViewDetail extends ViewDetail { function display() { echo 'This is my addition to the DetailView<br>'; //call parent display method parent::display(); } }
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/View/index.html
6769d7b65ab0-8
//call parent display method parent::display(); } } If ./modules/<module>/views/view.detail.php does exist, you would create ./custom/modules/<module>/views/view.detail.php and extend the base <module>ViewDetail class with the name Custom<module>ViewDetail. ./custom/modules/<module>/views/view.detail.php <?php require_once('modules/<module>/views/view.detail.php'); class Custom<module>ViewDetail extends <module>ViewDetail { function display() { echo 'This is my addition to the DetailView<br>'; //call parent display method parent::display(); } } Display Options for Views
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/View/index.html
6769d7b65ab0-9
parent::display(); } } Display Options for Views The Sugar MVC provides developers with granular control over how the screen looks when a view is rendered. Each view can have a config file associated with it. In the case of an edit view, the developer would create the file ./customs/modules/<module>/views/view.edit.config.php . When the edit view is rendered, this config file will be picked up. When loading the view, ViewFactory class will merge the view config files from the following possible locations with precedence order (high to low): ./customs/modules/<module>/views/view.<view>.config.php ./modules/<module>/views/view.<view>.config.php ./custom/include/MVC/View/views/view.<view>.config.php ./include/MVC/View/views/view.<view>.config.php
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/View/index.html