我想在四次循环后添加新的行。我使用{section loop=$arrProducts name=index}当execute array将显示一行中的所有产品,但我希望每行添加四个产品。我能做什么?
感谢我使用的这段代码
{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} LE</span><br>
<font class="quality">QTY.</font><input type="text" name="txtorder" size="1" class="txtproduct" /><font class="quality"> Kg</font><br />
</td>
{/section}
{/if}发布于 2010-02-08 18:20:56
我总是使用聪明的数学来判断是否必须添加新行。它可能看起来像这样:
{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} LE</span><br>
<font class="quality">QTY.</font><input type="text" name="txtorder" size="1" class="txtproduct" /><font class="quality"> Kg</font><br />
</td>
{/section}
</tr>
{/if}https://stackoverflow.com/questions/2220805
复制相似问题