phpsource/템플릿
{템포2}5.다이나믹블록
방글24
2008. 7. 16. 01:11
written: Jul 16 2008
반복되는 블록요소
Case #1
[code html;gutter:false]
<table border="1">
<tr>
<th bgcolor="#000066" style="color:white;">classify</th>
<th bgcolor="#0000ff" style="color:white;">column1</th>
<th bgcolor="#0000ff" style="color:white;">column2</th>
<th bgcolor="#0000ff" style="color:white;">column3</th>
</tr>
<tempo id="eLoop">
<tr bgcolor="silver" style="height:30;">
<td align="center" bgcolor="#000066" style="color:white;">
<?=$column0?>
</td>
<td align="center"><?=$column1?></td>
<td align="center"><?=$column2?></td>
<td align="center"><?=$column3?></td>
</tr>
</tempo>
</table>
[/code]
< Template file : tempo.sample.htm >
[code php;gutter:false]
<?php
$columns[0]['column0'] = 'Country';
$columns[0]['column1'] = 'Korea';
$columns[0]['column2'] = 'USA';
$columns[0]['column3'] = 'Germany';
$columns[1]['column0'] = 'Capital city';
$columns[1]['column1'] = 'Seoul';
$columns[1]['column2'] = 'Washington DC';
$columns[1]['column3'] = 'Berlin';
$columns[2]['column0'] = 'Population';
$columns[2]['column1'] = '49,000,000';
$columns[2]['column2'] = '301,000,000';
$columns[2]['column3'] = '82,000,000';
include_once('class.Tempo2.php');
$tempo = &new Tempo2;
$tempo->parse('sample', 'tempo.sample.htm');
$tempo->el['eLoop']->assign('');
foreach ($columns as $column) {
extract($column);
$tempo->el['eLoop']->assign('.');
}
$tempo->el['sample']->assign();
$tempo->el['sample']->output();
?>
[/code]
< PHP coding >
< Result >