How to create a custom view of type Detail in Sugar CRM or Suite CRM
In SugarCRM CE 6.5 or in SuiteCRM there is the standard DetailView mask that allows you to Edit/Details 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 Detail to manage personalized Edit/Details 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 ViewDetail { 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 (
‘DetailView’ =>
array (
‘templateMeta’ =>
array (
‘form’ =>
array (
‘buttons’ =>
array (
0 => ‘EDIT’,
1 => ‘DELETE’,
),
),
‘maxColumns’ => ‘2’,
‘widths’ =>
array (
0 =>
array (
‘label’ => ’10’,
‘field’ => ’30’,
),
1 =>
array (
‘label’ => ’10’,
‘field’ => ’30’,
),
),
‘useTabs’ => false,
‘tabDefs’ =>
array (
‘DEFAULT’ =>
array (
‘newTab’ => false,
‘panelDefault’ => ‘expanded’,
),
),
),
‘panels’ =>
array (
‘default’ =>
array (
0 =>
array (
0 => ‘name’
),
),
),
),
);
?>
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