>对不起,我不知道如何问这个问题,因为我的知识很少。我将举一个例子来说明我正在尝试做的事情:
消息:no records found
,如果您在部门"7"中没有票
{if $ticket.did["7"] == ''}
No records found!
{/if}
我的 Whmcs tpl 代码:
{foreach from=$tickets item=ticket}
{if $ticket.did == '7'}
<tr>
<td>#{$ticket.tid}</td>
<td>{$ticket.title}</td>
<td>{$ticket.status}</td>
<td><a href="viewticket.php?tid={$ticket.tid}&c={$ticket.c}">View</a></td>
</tr>
{/if}
{/foreach}
{if $ticket.did["7"] == ''}
<tr>
<td colspan="6" class="textcenter">{$LANG.norecordsfound}</td>
</tr>
{/if}
谢谢!
您可以初始化新变量,并在满足循环中的条件时将其设置为 true。
{foreach from=$tickets item=ticket}
{if $ticket.did == '7'}
{assign var="ticketFound" value="true"}
<tr>
<td>#{$ticket.tid}</td>
<td>{$ticket.title}</td>
<td>{$ticket.status}</td>
<td><a href="viewticket.php?tid={$ticket.tid}&c={$ticket.c}">View</a></td>
</tr>
{/if}
{/foreach}
{if !$ticketFound}
<tr>
<td colspan="6" class="textcenter">{$LANG.norecordsfound}</td>
</tr>
{/if}