Nasıl dört smarty şablonları döngü sonra yeni bir satır eklemek

1 Cevap

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???

Hemde i kullanmak bu kodu ederiz

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

1 Cevap

Ben her zaman yeni bir satır eklemek zorunda olmadığını görmek için smarty matematik kullanılır. Böyle bir şey olabilir:

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