php – Listviewdefs中的SugarCRM Smarty代码
作者:互联网
我正在尝试使用Smarty PHP在SugarCRM(6.5.3)的ListView(custom / modules / Leads / metadata / listviewdefs.php)中进行自定义功能.
这很好用:
'customCode' => '{$LD_ASSUMED_SUGAR_ACCOUNT_ID_C}',
这样做:
'customCode' => '{$ACCOUNT_NAME}',
但是,这只是输出List中的代码(括号和所有)(但是使用Account name替换正确的值):
'customCode' => '{if $LD_ASSUMED_SUGAR_ACCOUNT_ID_C}{$ACCOUNT_NAME}{/if}',
我究竟做错了什么!?
解决方法:
我认为你不能像在EditView&中那样在ListView中获得相同的结果.详细视图.解决此问题的一种方法是向Leads vardefs添加非db字段,并使用逻辑挂钩来处理条件格式.
创建一个新的vardef:
/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
<?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,
),
希望有所帮助.
标签:sugarcrm,php,smarty 来源: https://codeday.me/bug/20190825/1723288.html