Let the platform do the work

Layoutdefs

Overview

The Layoutdefs extension adds or overrides subpanel definitions.

Note: This extension is only applicable to modules running in backward compatibility mode.

Properties

The following extension properties are available. For more information, please refer to the Extension Property documentation.

Property Value
Extension Scope Module
Sugar Variable $layout_defs
Extension Directory ./custom/Extension/modules/<module>/Ext/Layoutdefs/
Compiled Extension File ./custom/<module>/Ext/Layoutdefs/layoutdefs.ext.php
Manifest Installdef $installdefs['layoutdefs']

Implementation

The following sections illustrate the various ways to implement a customization to a Sugar instance.

File System

When working directly with the filesystem, you can create a file in ./custom/Extension/modules/<module>/Ext/Layoutdefs/ to add Layout Definition files to the system. The following example will add a subpanel definition for a module relationship:

./custom/Extension/modules/<module>/Ext/Layoutdefs/<file>.php

  <?php

$layout_defs["<module>"]["subpanel_setup"]['<subpanel key>'] = array (
    'order' => 100,
    'module' => '<related module>',
    'subpanel_name' => 'default',
    'sort_order' => 'asc',
    'sort_by' => 'id',
    'title_key' => 'LBL_SUBPANEL_TITLE',
    'get_subpanel_data' => '<subpanel key>',
    'top_buttons' => array (
        array (
          'widget_class' => 'SubPanelTopButtonQuickCreate',
        ),
        array (
          'widget_class' => 'SubPanelTopSelectButton',
          'mode' => 'MultiSelect',
        ),
    ),
);

Please note that, if you are attempting to override parts of an existing subpanel definition, you should specify the exact index rather than redefining the entire array. An example of overriding the subpanel top_buttons index is shown below:

  <?php

$layout_defs["<module>"]["subpanel_setup"]["<subpanel key>"]["top_buttons"] = array(
    array(
        'widget_class' => 'SubPanelTopButtonQuickCreate',
    ),
);

Next, navigate to Admin > Repair > Quick Repair and Rebuild. The system will then rebuild the extensions and compile your customizations to ./custom/modules/<module>/Ext/Layoutdefs/layoutdefs.ext.php .

Module Loadable Package

When building a module loadable package, you can use the $installdefs['layoutdefs'] index to install the extension file.

Installdef Properties

Name Type Description
from String The base path of the file to be installed
to_module String The key for the module where the file will be installed

The example below demonstrates the proper install definition that should be used in the ./manifest.php file in order to add the Layout Definition Extension file to the system. When using this approach, Sugar will automatically execute Rebuild Extensions to reflect the customizations added with the Layout definition.

./manifest.php

  <?php

$manifest = array(
    ...
);

$installdefs = array(
    'id' => 'layoutdefs_Example',
    'layoutdefs' => array(
        array(
            'from' => '<basepath>/Files/custom/Extension/modules/<module>/Ext/Layoutdefs/<file>.php',
            'to_module' => '<module>',
        )
    )
);

Alternatively, you may use the $installdefs['copy'] index to copy the file. When using this approach, you may need to manually run repair actions such as a Quick Repair and Rebuild. For more information on the $installdefs['copy'] index and module-loadable packages, please refer to the Introduction to the Manifest page.

Topics