[英]How can I output a comma separated string of values with opneTBS
using openTBS (in the SugarCRM plugin MailMergeReports) and I have the following in my Word template.使用 openTBS(在 SugarCRM 插件 MailMergeReports 中),我的 Word 模板中有以下内容。
[a_sub5;block=w:p;nodata] No States
[a_sub5;block=w:p][a_sub5.name]
This works fine as far as it goes - it outputs a single state name per line - which is fine when the data only has a few states.就目前而言,这很好用——它每行输出一个状态名称——当数据只有几个状态时,这很好。
The problem is I want it to output the list of states as a comma separated string rather than 1 state per line.问题是我希望它将状态列表输出为逗号分隔的字符串,而不是每行 1 个状态。 I have tried multiple options with no luck!
我尝试了多种选择,但都没有运气! Is this not possible to do?
这是不可能的吗? or am I just missing the obvious syntax needed to accomplish it.
或者我只是缺少完成它所需的明显语法。
Note: because I am using TB via a 3rd party plugin to SugarCRM CE I do not have ready access to the PHP code.注意:因为我通过 SugarCRM CE 的 3rd 方插件使用 TB,所以我无法访问 PHP 代码。 I need a solution that can be accomplished just within the template specification.
我需要一个可以仅在模板规范内完成的解决方案。
If you had no the nodata
section, you could try with [a_sub5.nom;block=!w:r],
but this would add an extra coma at the end of the list.如果您没有
nodata
部分,您可以尝试使用[a_sub5.nom;block=!w:r],
但这会在列表末尾添加一个额外的昏迷。 This doesn't work since you have the nodata
section because the 2 TBS sections are not continuous, thus it will produce an invalid XML.这不起作用,因为您有
nodata
部分,因为 2 个 TBS 部分不连续,因此会产生无效的 XML。
My advice is to format your list at the TBS side, then merge it into the template :我的建议是在 TBS 端格式化您的列表,然后将其合并到模板中:
PHP : PHP :
$list = array_column($data, 'name');
$list = implode(', ', $list);
if ($list == '') $list = "No States";
TBS->MergeField('a_sub5', $list);
Template:模板:
[a_sub5]
If is a sub-block, then you can use a onformat custom function for making the list.如果是子块,那么您可以使用onformat自定义函数来制作列表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.