Let the platform do the work

Modules

Overview

The Modules extension maps additional modules in the system, typically when Module Builder deploys a module.

Properties

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

Property Value
Extension Scope Application
Sugar Variable $beanList, $beanFiles, $moduleList
Extension Directory ./custom/Extension/application/Ext/Include/
Compiled Extension File ./custom/application/Ext/Include/modules.ext.php
Manifest Installdef $installdefs['beans']

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/application/Ext/Include/ to register a new module in the system. This extension is normally used when deploying custom modules. The example below shows what this file will look like after a module is deployed:

./custom/Extension/application/Ext/Include/<file>.php

  <?php

$beanList['cust_module'] = 'cust_module';
$beanFiles['cust_module'] = 'modules/cust_module/cust_module.php';
$moduleList[] = 'cust_module';

Next, navigate to Admin > Repair > Quick Repair and Rebuild. The system will then rebuild the extensions and compile your customization into ./custom/application/Ext/Include/modules.ext.php.

Module Loadable Package

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

Installdef Properties

Name Type Description
module String The key of the module to be installed
class String The class name of the module to be installed
path String The path to the module's class
tab Boolean Whether or not the module will have a navigation tab (defaults to false)

The example below demonstrates the proper install definition that should be used in the ./manifest.php file, in order to add a custom module to the system. When using this approach, you still need to use the $installdefs['copy'] index for Module directory, however, Sugar will automatically execute the database table creation process, relationship table creation process, as well as Rebuild Extensions to reflect the new Module in the system.

./manifest.php

  <?php

$manifest = array(
    ...
);

$installdefs = array(
    'id' => 'Beans_Example',
    'beans' => array(
        array(
            'module' => 'cust_Module',
            'class' => 'cust_Module',
            'path' => 'modules/cust_Module/cust_Module.php',
            'tab' => true
        )
    ),
    'copy' => array(
        array(
            'from' => '<basepath>/Files/modules/cust_Module',
            'to' => 'modules/cust_Module'
        )
    )
);

Alternatively, you may use the $installdefs['copy'] index for copying the Modules definition file into the ./custom/Extension/application/Ext/Include/ directory. 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