{if $smarty.section.outer.index is odd by 2}
Posted on 2008-06-13 10:24 analyzer 阅读(1058) 评论(0) 收藏 举报{if $smarty.section.outer.index is odd by 2}
test.tpl
1
<table border=1>
2
{section name=outer loop=$FirstName}
3
{if $smarty.section.outer.index is odd by 3}
4
<tr bgcolor="#EFEFEF"><td>
5
{$smarty.section.outer.index}-{$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
6
</td></tr>
7
{else}
8
<tr bgcolor="#FFFFFFF"><td>
9
{$smarty.section.outer.index}-{$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
10
</td></tr>
11
{/if}
12
{sectionelse}
13
none
14
{/section}
15
16
</table>
<table border=1>2
{section name=outer loop=$FirstName}3
{if $smarty.section.outer.index is odd by 3}4
<tr bgcolor="#EFEFEF"><td>5
{$smarty.section.outer.index}-{$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}6
</td></tr>7
{else}8
<tr bgcolor="#FFFFFFF"><td>9
{$smarty.section.outer.index}-{$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}10
</td></tr>11
{/if}12
{sectionelse}13
none14
{/section}15

16
</table>test.php
1
<?php
2
3
require 'lib/Smarty-2.6.11/libs/Smarty.class.php';
4
5
$smarty = new Smarty;
6
7
//$smarty->compile_check = true;
8
//$smarty->debugging = true;
9
10
//$smarty->assign("hello","byby");
11
$smarty->assign("FirstName",array("John","Mary","James","Henry","Tom","Hello"));
12
13
$smarty->display('test.tpl');
14
15
?>
<?php2

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

5
$smarty = new Smarty;6

7
//$smarty->compile_check = true;8
//$smarty->debugging = true;9

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

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

15
?>{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 |
浙公网安备 33010602011771号