Whether you’re making your own module, an integration or just a special something-something for your company’s SugarCRM instance, there comes a time when you may want to create a nice page to hold some administrative configuration settings. The best place to put these types of things is on the “Admin” area of Sugar.
The $admin_group_header variable is the array that holds the metadata that determines what the layout of the admin page looks like. To add new links to the admin page, all you need to do is alter the array accordingly in a custom Ext file. To test this out, create a file named abc_Module.php in the following directory: /custom/Extension/modules/Administration/Ext/Administration/ If the directory path does not exist, simply create the folders needed.
Copy and paste the code below into the new file and save. Now, go to SugarCRM and run a “Quick Repair and Rebuild”. This will merge the existing admin options with the new admin options we’ve created.
<?php | |
// initialize a temp array that will hold the options we want to create | |
$links = array(); | |
// add button1 to $links | |
$links['abc_Module']['link1'] = array( | |
// pick an image from /themes/Sugar5/images | |
// and drop the file extension | |
'Releases', | |
// title of the link | |
'Link 1 Title', | |
// description for the link | |
'The description for what link 1 will do. Put whatever you want here.', | |
// where to send the user when the link is clicked | |
'./index.php?module=abc_Module&action=link1_action', | |
); | |
// add link2 to $links | |
// this link uses labels instead of hard-coded strings | |
// since this is in the scope of the Administration module, | |
// you need to add these labels to the | |
// Administration lang files in | |
// /custom/Extension/modules/Administration/Ext/Language/abc_Module.php | |
$links['abc_Module']['link2'] = array( | |
// pick an image from /themes/Sugar5/images | |
// and drop the file extension | |
'CallReports', | |
// defined in /custom/Extension/modules/Administration/Ext/Language/abc_Module.php | |
'LBL_ABC_MODULE_LINK2_TITLE', | |
// defined in /custom/Extension/modules/Administration/Ext/Language/abc_Module.php | |
'LBL_ABC_MODULE_LINK2_DESCRIPTION', | |
// where to send the user when the link is clicked | |
'./index.php?module=abc_Module&action=link2_action', | |
); | |
// add our new admin section to the main admin_group_header array | |
$admin_group_header []= array( | |
// The title for the group of links | |
'abc_Module Admin Options', | |
// leave empty, it's used for something in /include/utils/layout_utils.php | |
// in the get_module_title() function | |
'', | |
// set to false, it's used for something in /include/utils/layout_utils.php | |
// in the get_module_title() function | |
false, | |
// the array of links that you created above | |
// to be placed in this section | |
$links, | |
// a description for what this section is about | |
'The description for what abc_Module configuration options can do for you.' | |
); |
To see exactly what the code is doing, see the comments in the code.
If you installed this on your system as is, you’ll notice the title and description to “Link 2” show up as a language file label name. Because the scope of the page is within the Administration module, you’ll need to add the labels to the Administration module’s language files. You can do this by creating another extension file named en_us.abc_Module.php (using your language prefix of choice) in the /custom/Extension/modules/Administration/Ext/Language folder. The code should look something like the following (Notice the label names match up to the previous code):
<?php | |
$mod_strings['LBL_ABC_MODULE_LINK2_TITLE'] = 'Link 2 Title'; // title of the link | |
$mod_strings['LBL_ABC_MODULE_LINK2_DESCRIPTION'] = 'The description for what link w will do. Put whatever you want here.'; // description for the link |
Like before, after running a “Quick Repair and Rebuild”, the changes will be applied, and the labels from the new language file will be pulled onto the admin options page.
To dig deeper into how SugarCRM uses the $admin_group_header array to process the admin page you’ll want to start here: /modules/Administration/index.php. Look for a line that contains “foreach ($admin_group_header as $key=>$values)”. This is where the code begins to loop through the array and build the page.
It’s that simple. Is this how you would have solved the problem? If you have any related tips on this same topic, let everyone know in the comments!
-
SalesRoller
Link **Xero Cloud Accounting** and **SugarCRM** for the full 360 degree view of your customer information. -
HubSpot Integration for Sugar by Faye
FEATUREDFaye's Sugar Hubspot Integration supports bi-directional sync for key records, one-way synchronization for activities, and flexible field mapping options. -
ZINFI Partner Portal for SugarCRM
FEATUREDManage your business partners quickly and easily using ZINFI Unified Partner Management portal and SugarCRM to sync data and get real time record management and data flow! - Show more addons