1
我想每行顯示3個圖像。但代碼顯示第一行2(2)圖像,然後顯示下一行3圖像。代碼的問題在哪裏?每行顯示3個圖像
<table style="width: 99%;padding-top:30px;" dir="ltr" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
{foreach from=$execommittee item=v name=cat}
{if $smarty.foreach.cat.iteration % 3 == 0 && $smarty.foreach.cat.iteration > 0}
</tr>
<tr>
{/if}
<td width="142">
<p style="text-align: center;" align="justify">
<img src="themes/{$themes}/resources/images/publications/{$v.efilename}" border="0" width="142" height="152" /></a></p>
<p style="text-align: center;" align="justify">{$v.ename}</p>
</td>
{/foreach}
</tr>
</tbody>
</table>
'$ smarty.foreach.cat.iteration'總是會大於0,因爲它開始於1(http://www.smarty.net/docsv2/en/language.function.foreach.tpl#foreach。 property.iteration),所以你不需要在你的'if'語句中有這個。 – guessimtoolate