简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM