Table of Contents Previous Next

Sugar Developer Guide

Version 5.1


Chapter 4 Customizing Sugar : User Interface Customizations : Overriding the View

Overriding the View
Using the MVC framework, you define your module's own view.edit.php or view.detail.php file to subclass ViewEdit (for EditView) or ViewDetail (for DetailView). Then you override either the process or display methods to do any intermediary processing as necessary. This technique should be employed when you still want to take advantage of the rendering/layout formatting done by the metadata framework, but wish to tweak how some of the values are retrieved.
// Contents of module/[$module]/view/view.edit.php file
require_once('include/json_config.php');
require_once('include/MVC/View/views/view.edit.php');
class CallsViewEdit extends ViewEdit {
function CallsViewEdit(){
parent::ViewEdit();
}
 
function display() {
global $json;
$json = getJSONobj();
$json_config = new json_config();
if (isset($this->bean->json_id) && !empty ($this->bean->json_id)) {
$JavaScript = $json_config->get_static_json_server(false, true, 'Calls', $this->bean->json_id);
} else {
$this->bean->json_id = $this->bean->id;
$JavaScript = $json_config->get_static_json_server(false, true, 'Calls', $this->bean->id);
}
 
// Assign the Javascript code to Smarty .tpl
$this->ss->assign('JSON_CONFIG_JAVASCRIPT', $JavaScript);
parent::display();
}
}

In the file modules/Calls/metadata/editviewdefs.php we have the following defined for the templateMeta->JavaScript value:
'JavaScript' => '<script type="text/JavaScript">{$JSON_CONFIG_JAVASCRIPT}</script>'
 
Here the $JSON_CONFIG_JAVASCRIPT Smarty variable was the result of a complex operation and not available via the vardefs.php file (i.e. there is no JSON_CONFIG_JAVASCRIPT declaration in the vardefs.php file).

Table of Contents Previous Next

Copyright 2004-2008 SugarCRM Inc.
Product License