Action links are hooks into the user interface that can be created directly in the database without having to change any code. At most you will have to create new code to attend to the new actions.
These actions will be easily upgradeable going forward as they are saved in the database and no base code changes are required.
Adding a new action can be done in two ways. The first is when creating a module in it's manifest file. There is a specific section there to add custom links that looks like this:
The above code is extracted from the coreBOSUpdater manifest.xml file. It adds a DETAILVIEWWIDGET and a LISTVIEWBASIC action. As can be seen the action has these parameters:
|linktype||Type of Link like DETAILVIEW etc..|
|linklabel||Label to use for the link when displaying (will be translated)|
|linkurl||URL of the action link. You can use the special variables $RECORD$ which will evaluate to the current record ID and $MODULE$ which evaluates to the current module|
|linkicon||path to a small 16×16 icon to show before the DETAILVIEWBASIC action link|
|sequence||order in which the actions should be displayed|
|handler_path||currently not used|
|handler_class||currently not used|
|handler||currently not used|
The second form is for when we have an already installed module and we want to modify it. In this case we have to load the vtlib programming API, get a link to our module and execute the addLink() method. This looks like this:
include_once('vtlib/Vtiger/Module.php'); $module = Vtiger_Module::getInstance('Contacts'); $module->addLink('LISTVIEWBASIC', 'LBL_SELECT_ALL', 'toggleSelectAllEntries_ListView();');
include_once('vtlib/Vtiger/Module.php'); $mod_acc = Vtiger_Module::getInstance('Accounts'); $mod_acc->addLink('DETAILVIEWBASIC', 'Add Ticket', 'index.php?module=HelpDesk&action=EditView&parent_id=$RECORD$');
The first example adds a button to the list view of the contacts module while the second adds a link to the right action panel of accounts.
You can get a copy of the full script in the build/HelperScripts directory of coreBOS.
We have two possible options on the list view. The LISTVIEWBASIC value will add a new button on the list view exactly the same as the already existing buttons, while the LISTVIEW value will add the link to a “More actions” drop down menu.
We have three types of possible actions on the detail view screen. The DETAILVIEWBASIC option will add a link to the right action panel, at the same level as the normal existing links. The DETAILVIEW option will add the link inside a “More Actions” drop down menu. This is useful when we have many options.
Finally the DETAILVIEWWIDGET option will permit us to add a small widget (box) on the right action panel, within which we will be able to execute some actions. Very useful to add functionality to the module.
The DETAILVIEWWIDGET URL is called within the context of the application, it does not need index.php because that will be called always. You simply have to add the MVC parameters. This will normally be in the form;
|LISTVIEWBASIC||Button on the list view|
|LISTVIEW||Drop down menu on the list view|
|DETAILVIEW||Drop down menu on the right action panel in detail view|
|DETAILVIEWBASIC||Link on the right action panel in detail view|
|DETAILVIEWWIDGET||Small widget block section at the bottom of the right action panel on detail view. Look at the Timecontrol stopwatch for an example. It can also be a full fledged block inserted into the existing field blocks|
|HEADERCSS||The link will be treated as a CSS type and will be imported in the head section of the HTML output page as <link rel='stylesheet' type='text/css' href='linkurl>|
|HEADERLINK||You can see these link grouped under More on the top header panel. Useful if you want to provide utility tools like Bookmarklet etc.|