SugarCRM
Inserting Dynamic Content in Metadata
Author:
Brief:
Inserting dynamic code into the Metadata Placeholder of SugarCRM.
e.g.
Adding dynamic drop down in the metadata placeholder like metadata/editviewdefs.php or metadata / searchdefs.php.
Observations:
Recommendations:
· Use the PHP best practices.
· Make database call if necessary by making separate functions.
· Try to override the methods of the /MVC/View/views/view.edit.php class.
Impact:
· This will reduce the extra
· Version compatibility.
To-do:
1) Create a folder views in your root/modules folder
2) Create a file with the name view.edit.php in your views folder created in step 1
3) Create a class with name
e.g. Module: Contacts Class = ContactsViewEdit
4) Extend the class to ViewEdit from the include/MVC/View/views/view.edit.php
5) Override the display() method in this file and add a line
$something=’
6) Add on next line
$this->ss->assign(‘newvariable’, $something)
7) Define a smarty variable in Metadata (vardefs file) like
e.g.
2 =>
array (
0 =>
array (
'name' => 'stage',
'label' => 'LBL_STAGE',
‘customCode’ => ‘{$newvariable}’
),
1 => NULL,
2=>NULL,
),
8) Clear the SugarCRM module cache + Browser cache and cokkies.
9) Run the code
The $newvariable will be replaced by the $something code.