Listviewdefs 中的 SugarCRM Smarty 代码 [英] SugarCRM Smarty Code in Listviewdefs
问题描述
我正在尝试使用 Smarty PHP 在 SugarCRM (6.5.3) 的 ListView (custom/modules/Leads/metadata/listviewdefs.php) 中实现自定义功能.
I'm trying to use Smarty PHP for custom functionality in the ListView (custom/modules/Leads/metadata/listviewdefs.php) of SugarCRM (6.5.3).
这很好用:
'customCode' => '{$LD_ASSUMED_SUGAR_ACCOUNT_ID_C}',
这也是:
'customCode' => '{$ACCOUNT_NAME}',
然而,这只是输出列表中的代码(括号和所有)(但帐户名称替换为正确的值):
However this just outputs the code (brackets and all) in the List (but with Account name substituted for the correct value):
'customCode' => '{if $LD_ASSUMED_SUGAR_ACCOUNT_ID_C}{$ACCOUNT_NAME}{/if}',
我做错了什么!?
推荐答案
我认为您无法像在 EditView & 中那样在 ListView 中获得相同的结果.详细视图.解决此问题的一种方法是将非数据库字段添加到 Leads vardefs 并使用逻辑挂钩来处理条件格式.
I don't think you can achieve the same result you are looking for in ListView like you can in EditView & DetailView. One way to go about this is to add a non-db field to Leads vardefs and use a logic hook to handle conditional formatting.
创建一个新的 vardef:
/custom/Extension/modules/Cases/Ext/Vardefs/my_listview_value_c.php
/custom/Extension/modules/Cases/Ext/Vardefs/my_listview_value_c.php
<?php
$dictionary['Lead']['fields']['my_listview_value_c'] = array(
'name' => 'my_listview_value_c',
'vname' => 'LBL_MY_LISTVIEW_VALUE_C',
'type' => 'varchar',
'len' => '255',
'source' => 'non-db',
);
?>
创建逻辑钩子:
/custom/modules/Leads/ListViewLogicHook.php
/custom/modules/Leads/ListViewLogicHook.php
<?php
class ListViewLogicHook {
public function getListValue(&$bean, $event, $arguments) {
if ($bean->ld_assumed_sugar_account_id_c) {
$bean->my_listview_value_c = $bean->account_name;
} else {
// Whatever you'd like
}
}
}
添加逻辑钩子入口:
// position, file, function
$hook_array['process_record'] = Array();
$hook_array['process_record'][] = Array(1, 'Conditional formatting in a listview column', 'custom/modules/Leads/ListViewLogicHook.php','ListViewLogicHook','getListValue');
最后,在您的 listviewdefs 中添加新列:
'MY_LISTVIEW_VALUE_C' =>
array (
'width' => '10%',
'label' => 'LBL_MY_LISTVIEW_VALUE_C',
'default' => true,
),
希望有所帮助.
这篇关于Listviewdefs 中的 SugarCRM Smarty 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!