AnsweredAssumed Answered

Add custom code to the record view on SugarCRM 7.5

Question asked by Oscar Castro on Feb 19, 2016
Latest reply on Feb 19, 2016 by Rodolfo Jesus

Hi,

On SugarCRM C.E 6.5 i can add a custom code to the edit or detail view through Smarty like this:

'lbl_editview_panel1' => 
  array (
    0 => 
    array (
      0 => 
      array (
        'name' => 'Items',
        'label' => 'LBL_ITEMS',
        'customCode' => '{show_items parent_id=$fields.id.value fields=$fields view="edit"}',
      ),
    ),
  ),

 

Calling a Smarty function and return a .tpl file:

<?php
    function smarty_function_show_items($params, &$smarty) {
        $parent_id = $params['parent_id'];

        $items=FnCrm::getItems($parent_id); //Search and return the items from the db
        $smarty->assign('items', $items);

        return $smarty->fetch("custom/partials/Items/item.tpl");
    }
?>

 

And the .tpl content:

<table>
  <tr>
    <th>Ref.</th>
    <th>Name</th>
    <th>Description</th>
    <th>Price</th>
  </tr>
  {foreach key=key item=item from=$items}
    <tr>
      <td>{$item.ref}</td>
      <td>{$item.name}</td>
      <td>{$item.description}</td>
      <td>{$item.price}</td>
    </tr>
  {/foreach}
</table>

 

The question is, what is the best solution to implement a custom code like this on a single module on SugarCRM 7 through Sidecar and Handlebars?

 

Thanks for the help.

Outcomes