| GHengeveld |
|
|---|---|
|
Within the foreach, you need to do a parse('MAIN.TEST_ROW'), not an out(). At the end of your file, you need to do this:
$t->parse('MAIN');
$t->out('MAIN');
Usually you use out() only once: for the MAIN block at the end of your php code. You can omit the 'MAIN' in out(), because it's the default value. To seperate your html code for a=update you may want to add the UPDATE block. Also, you'll often want to be able to show a message if there aren't any results:
if ($a == 'update') {
$rows = $res->fetchAll();
if ($rows) {
foreach ($rows as $row) {
$t->assign(array(
'TEST_USERNAME' => cot_build_user($row['test_userid'], htmlspecialchars($row['test_username'])),
'TEST_MESSAGE' => cot_parse($row['test_message'], $cfg['plugin']['comments']['markup']),
'TEST_DATE' => cot_date('M jS', $row['test_date']),
'TEST_DATETIME' => cot_date('G:i', $row['test_date'])
));
$t->parse('MAIN.UPDATE.ROWS.ROW');
}
$t->parse('MAIN.UPDATE.ROWS');
} else {
$t->parse('MAIN.UPDATE.NO_ROWS');
}
$t->parse('MAIN.UPDATE');
}
$t->parse('MAIN');
$t->out();
A complete tpl could look like this:
<!-- BEGIN: MAIN -->
<!-- BEGIN: UPDATE -->
<div id="update">
<!-- BEGIN: ROWS -->
<table>
<thead>
<tr>
<th>Username</th>
<th>Message</th>
<th>Date</th>
<th>Datetime</th>
</tr>
</thead>
<tbody>
<!-- BEGIN: ROW -->
<tr>
<td>{TEST_USERNAME}</td>
<td>{TEST_MESSAGE}</td>
<td>{TEST_DATE}</td>
<td>{TEST_DATETIME}</td>
</tr>
<!-- END: ROW -->
</tbody>
</table>
<!-- END: ROWS -->
<!-- BEGIN: NO_ROWS -->
None
<!-- END: NO_ROWS -->
</div>
<!-- END: UPDATE -->
<!-- END: MAIN -->
This post was edited by GHengeveld (2012-10-04 07:37, 13 years ago)
|