簡體   English   中英

在Smarty模板中循環四次后如何添加新行

[英]How add new line after four looping in smarty templates

我想在四次循環后添加新行。 我在執行數組時使用{section loop = $ arrProducts name = index}會在一行中顯示所有產品,但是我想在一行中添加每四個產品。 我能做什么???

謝謝我使用的這段代碼

{if $arrProducts neq " "}
{section loop=$arrProducts name=index}
<td width="565" align="center" valign="top">

<img src="admin/{$arrProducts[index].image}" width="121" height="90" class="prodImg"/><br>
<span class="prodName">{$arrProducts[index].name}</span><br>
<span class="prodPrice">{$arrProducts[index].price}&nbsp;LE</span><br>
<font class="quality">QTY.</font><input type="text" name="txtorder" size="1" class="txtproduct" /><font class="quality">&nbsp;Kg</font><br />
</td>
{/section}
{/if}

我總是用聰明的數學來看看是否必須添加新行。 它可能看起來像這樣:

{if $arrProducts neq " "}
<tr>
{section loop=$arrProducts name=index}
{if $index % 4 == 0}
</tr><tr>
{/if}
<td width="565" align="center" valign="top">

    <img src="admin/{$arrProducts[index].image}" width="121" height="90" class="prodImg"/><br>
    <span class="prodName">{$arrProducts[index].name}</span><br>
    <span class="prodPrice">{$arrProducts[index].price}&nbsp;LE</span><br>
    <font class="quality">QTY.</font><input type="text" name="txtorder" size="1" class="txtproduct" /><font class="quality">&nbsp;Kg</font><br />
</td>
{/section}
</tr>
{/if}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM