I want to modify the Smarty template sites/all/modules/civicrm/templates/CRM/Case/Audit/Report.tpl. I want to complement an existing foreach expression with comparing the incoming variable $group.title to an array of titles, and execute the following code only if the current $group.title is found in that array.
{assign var=visible-fields value=['value1, value2']}
<div> Visible fields var: {$visible-fields} </div>
{if $group.title|in_array:$visible-fields}
<h2>{$group.title}</h2>
<table class ="report-layout">
{foreach from=$group.values item=row}
<tr>
<th class="label">{$row.label}</td>
<td class="crm-case-report-custom-field">{$row.value}</td>
</tr>
{/foreach}
</table>
{/if}
Now, I'm getting stuck on a rather simple task: The array visible-fields
is not created. I have found some forum threads from the 2000s suggesting some expressions. I have tried the following, none of which seems to work:
{assign var=visible-fields value=['value1, value2']}
{assign var=visible-fields value=['value1', 'value2']}
{assign var='visible-fields' value=['value1, value2']}
- and the same with "" instead of ''
{assign var="visible-fields" value=","|explode:['value1, value2']}
Printing the variable with <div> Visible fields var: {$visible-fields} </div>
results in a 0.
I also tried solving the problem with a {php}...{/php}
block, but then the web app throws an error. Maybe I have to enable the support for these inline php blocks somewhere, but before trying that, I want to try solving it with the Smarty expression, because creating an array shouldn't be so difficult, right?
Can somebody tell me how to do it, or post a link?
$visible_fields
? I don't think smarty variables can have dashes: smarty.net/docsv2/en/language.syntax.variables.tpl