简体   繁体   English

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

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

i want to add new line after four looping. 我想在四次循环后添加新行。 i using {section loop=$arrProducts name=index} when execute array will show all products in one line but i want to add every four products in line. 我在执行数组时使用{section loop = $ arrProducts name = index}会在一行中显示所有产品,但是我想在一行中添加每四个产品。 what can i do??? 我能做什么???

Thank You this code i use 谢谢我使用的这段代码

{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}

I always used the smarty math to see if I have to add a new row. 我总是用聪明的数学来看看是否必须添加新行。 It could look something like this: 它可能看起来像这样:

{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