以下是 书中给出的代码
{* products_list.tpl *}
{load_presentation_object filename="products_list" assign="obj"}
{if $obj->mProducts}
<table class="product-list" border="0">
<tbody>
{section name=k loop=$obj->mProducts}
{if $smarty.section.k.index % 2 == 0}
<tr>
{/if}
<td valign="top">
<h3 class="product-title">
<a href="{$obj->mProducts[k].link_to_product}">
{$obj->mProducts[k].name}
</a>
</h3>
<p>
{if $obj->mProducts[k].thumbnail neq ""}
<a href="{$obj->mProducts[k].link_to_product}">
<img src="{$obj->mProducts[k].thumbnail}"
alt="{$obj->mProducts[k].name}" />
</a>
{/if}
{$obj->mProducts[k].description}
</p>
<p class="section">
Price:
{if $obj->mProducts[k].discounted_price != 0}
<span class="old-price">{$obj->mProducts[k].price}</span>
<span class="price">{$obj->mProducts[k].discounted_price}</span>
{else}
<span class="price">{$obj->mProducts[k].price}</span>
{/if}
</p>
</td>
{if $smarty.section.k.index % 2 != 0 && !$smarty.section.k.first ||
$smarty.section.k.last}
</tr>
{/if}
{/section}
</tbody>
</table>
{/if}
我不清楚以下行
{if $smarty.section.k.index % 2 == 0}
为什么要写上面的语句来查看索引是偶数还是奇数这对显示的表格有什么影响?