How to create a custom view of type List in Sugar CRM or Suite CRM
In SugarCRM CE 6.5 or in SuiteCRM there is the standard ListView mask that allows you to Filter/Exports/Delete/Edit an object of a specific module, there is also the Send Mail/SMS that can be used to quickly access an object.
These two masks are standard and easy to manage with Studio.
Sometimes, however, it can be useful to create a custom view of type List to manage personalized Filter/Exports/Delete/Edit to be used in specific cases.
To obtain this you need 3 steps:
create the view in
custom/modules/
/views/view. .php;
create the view in
custom/modules/
/controller.php;
define the view in
custom/modules/
/metadata/ viewdefs.php
After a “Quick Repair and Rebuild”, you are allowed to call the view with a link like this
/index.php?module= &action= &record=
eventually followed with other parameters you may need (managed in the file view.
Let’s start with the file
custom/modules/
/views/view. .php:
View
extends ViewList { public function preDisplay() {
$this->type = ‘‘;
parent::preDisplay();
$this->ev->view = ‘View’;
}public function display() {
parent::display();
}}
?>
Let’s examine the file
custom/modules/
/controller.php:
Controller extends SugarController {
public function action_
() {
$this->view = ‘‘;
}}
?>
Finally the file
custom/modules/
/metadata/ viewdefs.php
that will have the same syntax of the file
custom/modules/
/metadata/ viewdefs.php:
‘;
$_object_name = ‘‘;
$viewdefs [$module_name] =
array (
‘NAME’ =>
array (
‘width’=> ‘32%’,
‘label’=>’LBL_NAME’,
‘default’=>true,
‘link’=>true,
),
‘GROUP_COUNT’ =>
array(
‘type’ => ‘varchar’,
‘label’=> ‘LBL_GROUP_COUNT’,
‘width’=> ‘10%’,
‘default’=>true,
),
‘DATE_ENTERED’=>
array(
‘type’=> ‘datetime’,
‘label’=>’LBL_DATE_ENTERED’,
‘width’=>’10%’,
‘default’=>true,
),
);
?>
In this example we put only the field “name”, but of course you can set it similarly to the file
custom/modules/
/metadata/ viewdefs.php