{if $smarty.section.outer.index is odd by 2}
test.tpl
<table border=1>
{section name=outer loop=$FirstName}
{if $smarty.section.outer.index is odd by 3}
<tr bgcolor="#EFEFEF"><td>
{$smarty.section.outer.index}-{$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
</td></tr>
{else}
<tr bgcolor="#FFFFFFF"><td>
{$smarty.section.outer.index}-{$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
</td></tr>
{/if}
{sectionelse}
none
{/section}

</table>test.php
<?php

require 'lib/Smarty-2.6.11/libs/Smarty.class.php';

$smarty = new Smarty;

//$smarty->compile_check = true;
//$smarty->debugging = true;

//$smarty->assign("hello","byby");
$smarty->assign("FirstName",array("John","Mary","James","Henry","Tom","Hello"));

$smarty->display('test.tpl');

?>
{if $smarty.section.outer.index is odd by 1}
{if $smarty.section.outer.index is odd by 2}
{if $smarty.section.outer.index is odd by 3}































{if $smarty.section.outer.index is odd by 1}
0 -1 * John |
1 -2 . Mary |
2 -3 * James |
3 -4 . Henry |
4 -5 * Tom |
5 -6 . Hello |
{if $smarty.section.outer.index is odd by 2}
0 -1 * John |
1 -2 * Mary |
2 -3 . James |
3 -4 . Henry |
4 -5 * Tom |
5 -6 * Hello |
{if $smarty.section.outer.index is odd by 3}
0 -1 * John |
1 -2 * Mary |
2 -3 * James |
3 -4 . Henry |
4 -5 . Tom |
5 -6 . Hello |
posted on 2005-12-27 16:21 bluesky 閱讀(2055) 評論(1) 編輯 收藏 所屬分類: 記事本