2010-02-08 56 views
0

我想在四次循环后添加新行。我使用{节循环= $ arrProducts名称=索引} 当执行数组将显示在一行中的所有产品,但我想添加每四行产品。我能做什么???如何在smarty模板中循环四次后添加新行

谢谢这段代码我使用

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

回答

0

我总是使用Smarty的数学,看看我是否要添加一个新行。它可能是这个样子:

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

谢谢 但你的代码显示为V对齐 – 2010-02-08 14:17:03

+0

所有产品你是什么意思? – Daff 2010-02-18 23:31:48