• No results found

The Custom Directory

In document Sugar Developer Guide 6.2.0 (Page 123-127)

The Sugar system contains a top level directory called “custom” directory. This directory contains metadata files and custom code that override and extend the base Sugar functionality. Some of the files in this directory are auto-generated by the Module Builder, Studio, and Workflow tools (Sugar Professional and Sugar Enterprise only) and other files can be added or modified directly by a developer. Before discussing how a developer can use Sugar tools to modify the application, an understanding of the custom directory is useful.

124

Vardefs

Vardefs define field attributes for a given module. Existing vardefs can be modified and new vardefs can be created by modifying vardefs files in the custom directory.

Master Directories

Files in these directories can be edited and new files can be added to these directories.

/custom/Extension/modules/<MODULE_NAME>/Ext/Vardefs/

Production Directories

Files in these directories are auto-generated by the system and should not be modified.

/custom/modules/<MODULE_NAME>/Ext/Vardefs/vardefs.ext.php Description

Vardefs files either replace field definitions entirely, or add to the ones that are available to a module. In the Master Directories you can have many files such as:

/custom/Extension/modules/Calls/Ext/Vardefs/New_vardefs.php /custom/Extension/modules/Calls/Ext/Vardefs/Updated_Vardefs.php

During the repair function (Admin->Repair->Quick Repair and Rebuild), all of these files will be merged together into the production directory and they become the file:

/custom/modules/Calls/Ext/Vardefs/vardefs.ext.php

For example, a vardefs extension file for the Calls module could contain the following:

/custom/Extension/modules/Calls/ext/Vardefs/Import_Vardefs.php

<?php

$dictionary['Call']['fields']['parent_type']['vname'] = 'LBL_PARENT_TYPE';

$dictionary['Call']['fields']['parent_id']['vname'] = 'LBL_PARENT_ID';

$dictionary['Call']['fields']['deleted']['importable'] = false;

$dictionary['Call']['fields']['related_id'] = array ( 'name' => 'related_id',

'vname' => 'LBL_RELATED_ID', 'type' => 'id',

'required' => false, 'reportable' => false, 'audited' => true,

'comment' => 'ID of a related record of this call', );

?>

This would change the values for the “vname” of parent_type and parent_id, it would add an

“importable” value to the deleted field and set it to false and then add a whole new field called related_id to the calls field list.

125

Languages

It is possible to override display string values for a given language and create entirely new strings used by new custom fields.

Master Directories

Files in these directories can be edited and new files can be added to these directories.

/custom/include/language/ (for $app_strings or $app_list_strings) /custom/Extension/application/Ext/Include/

/custom/Extension/modules/<MODULE_NAME>/Ext/Language/ (for $mod_strings only)

Production Directories

Files in these directories are auto-generated by the system and should not be modified.

/custom/include/language/<LANGUAGE_TAG>.lang.ext.php

/custom/modules/<MODULE_NAME>/Ext/Languages/<LANGUAGE_TAG>.lang.ext.p hp

Description

Language files either replace entirely or add to the translated language items available to a module. In the Master Directories you can have many files like:

/custom/Extension/modules/Leads/Ext/Language/en_us.Custom_strings.php /custom/Extension/modules/Leads/Ext/Language/en_us.Custom_Languages.php

During the repair function (Admin->Repair->Quick Repair and Rebuild), all of these files will be merged together into the production directory and they become the file:

/custom/modules/Leads/Ext/Language/en_us.lang.ext.php

For example, a language extension file for the Calls module could contain the following:

/custom/Extension/modules/Calls/ext/Languages/en_us.Import_Menu.php

<?php

// adding Import field changes

$mod_strings['LNK_IMPORT_CALLS'] = 'Import Calls';

$mod_strings['LBL_MODIFIED_NAME'] = 'Modified By';

$mod_strings['LBL_PARENT_TYPE'] = 'Parent Type';

$mod_strings['LBL_PARENT_ID'] = 'Parent ID';

?>

This would add four new display strings to the Calls module.

126

Shortcuts

It is possible to override or create new Shortcuts menu items.

Master Directories

Files in these directories can be edited and new files can be added to these directories.

/custom/Extension/application/Ext/Menus/

/custom/Extension/modules/<MODULE_NAME>/Ext/Menus/

Production Directories

Files in these directories are auto-generated by the system and must not be modified.

/custom/application/Ext/Menus/menu.ext.php

/custom/modules/<MODULE_NAME>/Ext/Menus/menu.ext.php Description

Shortcut menu files either replace entirely, or add to the menu items available under the

“Actions” list on the module tabs. In the Master Directories you can have many files like:

/custom/Extension/modules/Calls/Ext/Menus/New_menu_items.php /custom/Extension/modules/Calls/Ext/Menus/Custom_Menus.php /custom/Extension/modules/Calls/Ext/Menus/Menu_items.php

During the repair function (Admin->Repair->Quick Repair and Rebuild), all of these files will be merged together into the production directory and they become the file:

/custom/modules/Leads/ext/Menus/menu.ext.php

For example, a menu extension file for the Calls module could contain the following:

<?php

if(ACLController::checkAccess('Calls', 'import', true)) {

$module_menu[]=Array("index.php?module=Calls&action=MakeIndex", translate('LNK_INDEX_CALLS'), "Import"

);

}

?>

This would add a menu item to the Calls module‟s Shortcuts menu. The $module_menu array takes three elements.

The first is the URL that the menu item will run.

127

The second is the text that will be shown on the menu, in this case we added some custom language text in a separate custom language file that we will go over later in this document.

The last is the name of the icon associated with this menu option. This word will have

“.gif” added to the end of it. If you want to use a png file here you must rename import.png to import.gif and load it into the themes/default/images directory. Even though it is named with the 'gif' extension it will still work.

If you added a $module_menu=array(); to the top of this file, you would effectively clear out any of the standard menu items. You could then replace them all with new definitions.

If the custom file is in the /custom/Extension/application/Ext/Menus/ directory, then your menu changes will affect shortcut menus in every module.

Layoutdefs

Master Directories

Files in these directories can be edited and new files can be added to these directories.

/custom/Extension/application/Ext/Layoutdefs/

/custom/Extension/modules/<MODULE_NAME>/Ext/Layoutdefs/

Production Directories

Files in these directories are auto-generated by the system and must not be modified.

/custom/application/Ext/Layoutdefs/layoutdefs.ext.php

/custom/modules/<MODULE_NAME>/Ext/Layoutdefs/layoutdefs.ext.php Rule

Use the following rule to add a sub-panel to a module:

For{$modulename}.php

In document Sugar Developer Guide 6.2.0 (Page 123-127)