Table of Contents Previous Next

Sugar Developer Guide

Version 5.1


Chapter 4 Customizing Sugar : Creating New Sugar Dashlets

Creating New Sugar Dashlets
The simplest Sugar Dashlet to create is a Module View. These are customizable ListViews of Sugar Dashlets. For this section we will use the MyAccountsDashlet as an example.
MyAccountsDashlet.php:
// include the base class
require_once('include/Dashlets/DashletGeneric.php');
// required for a seed bean
require_once('modules/Accounts/Account.php');
 
class MyAccountsDashlet extends DashletGeneric {
// takes an $id, and $def that contains the options/title/etc.
function MyAccountsDashlet($id, $def = null) {
require_once('MyAccountsDashlet.data.php');
parent::DashletGeneric($id, $def);
global $current_user, $app_strings;
$this->searchFields =
$DashletData['MyAccountsDashlet']['searchFields'];
$this->columns =
$DashletData['MyAccountsDashlet']['columns'];
All the metadata for this Sugar Dashlet is defined in the constructor. $searchFields are the search inputs that can be applied to the view. Defining these here will tell which input fields to generate corresponding filters when the user configures the Sugar Dashlet.
$columns define the available columns to the user. These contain the visible columns and the columns the user can make visible. These are defined in MyAccountsDashlet.data.php so that Studio can modify them easily.
// define a default title
if(empty($def['title'])) $this->title = ‘My Account Dashlet’;
$this->seedBean = new Account();
}
}
A seed bean is also required.
MyAccountsDashlet.data.php:
$DashletData['MyAccountsDashlet']['searchFields'] =
array('date_entered' => array('default' => ''));
$DashletData['MyAccountsDashlet']['columns'] = array(
'name' => array(
'width' => '40',
'label' => ‘LBL_LIST_ACCOUNT_NAME’,
'link' => true, // is the column clickable
'default' => true // is this column displayed by default
),
'billing_address_state' => array(
'width' => '8',
'label' => 'LBL_BILLING_ADDRESS_STATE’)
);
This file along with the .meta.php file is enough to create a generic Module View Sugar Dashlet.

Table of Contents Previous Next

Copyright 2004-2008 SugarCRM Inc.
Product License