Let the platform do the work

ActionFileMap

Overview

The ActionFileMap extension maps actions to files, which helps you map a file to a view outside of ./custom/modules/<module>/views/view.<name>.php. This page 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 $action_file_map
Extension Directory ./custom/Extension/modules/<module>/Ext/ActionFileMap/
Compiled Extension File ./custom/<module>/Ext/ActionFileMap/action_file_map.ext.php
Manifest Installdef $installdefs['action_file_map']

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/ActionFileMap/ to map a new action in the system. The following example will create a new action called "example" in a module:

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

<?php

$action_file_map['new_action'] = 'custom/modules/<module>/new_action.php';

Next, create your action file:

./custom/modules/<module>/new_action.php

<?php

//Encoded as JSON for AJAX layouts
echo '{"content":"Example View"}';

?>

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

Module Loadable Package

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

Installdef Properties

Name Type Description
from String The basepath of the file to be installed. 
to_module String The key of the module the file is to be installed to.

The example below demonstrates the proper install definition that should be used in the ./manifest.php file in order to add the Action File Map file to a specific module. You should note that when using this approach, you still need to use the $installdefs['copy'] index for the Action file, but Sugar will automatically execute Rebuild Extensions to reflect the new Action in the system.

./manifest.php

<?php

$manifest = array(
    ...
);

$installdefs = array(
    'id' => 'ActionRemap_Example',
    'action_file_map' => array(
        array(
            'from' => '<basepath>/Files/custom/Extension/modules/<module>/Ext/ActionFileMap/<file>.php',
            'to_module' => '<module>',
        )
    ),
    'copy' => array(
        array(
            'from' => '<basepath>/Files/custom/example.php',
            'to' => 'custom/example.php'
        )
    )
);

Alternatively, you may use the $installdefs['copy'] index for the Action File Map Extension 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.