Zo, ik heb nu het een en ander voor elkaar gekregen. Voor de lurkers de volgende bestanden:
In naw.php staat:
Code: Selecteer alles
<?php
// standard hack prevent
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
// standard session management
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
// set page title
$page_title = $lang['Index'];
// standard page header
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
// read naw
$sql = "select * from test";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
}
$template->assign_vars(array(
'L_NAAM' => 'Naam',
'L_ADRES' => 'Adres',
'L_POSTCODE' => 'Postcode',
'L_WOONPLAATS' => 'Woonplaats')
);
$i = 0;
while( $row = $db->sql_fetchrow($result) )
{
$naam = $row['naam'];
$adres = $row['adres'];
$postcode = $row['postcode'];
$woonplaats = $row['woonplaats'];
$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars('naamregel', array(
'ROW_COLOR' => $row_color,
'ROW_CLASS' => $row_class,
'NAAM' => $naam,
'ADRES' => $adres,
'POSTCODE' => $postcode,
'WOONPLAATS' => $woonplaats));
$i = $i + 1;
}
// assign template
$template->set_filenames(array(
'body' => 'naw.tpl')
);
$template->pparse('body');
// standard page footer
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>
In templates/fiblack3d/naw.tpl staat
Code: Selecteer alles
<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
<tr>
<th>{L_NAAM}</th>
<th>{L_ADRES}</th>
<th>{L_POSTCODE}</th>
<th>{L_WOONPLAATS}</th>
</tr>
<!-- BEGIN naamregel -->
<tr>
<td class="{naamregel.ROW_CLASS}" align="center">{naamregel.NAAM}</td>
<td class="{naamregel.ROW_CLASS}" align="center">{naamregel.ADRES}</td>
<td class="{naamregel.ROW_CLASS}" align="center">{naamregel.POSTCODE}</td>
<td class="{naamregel.ROW_CLASS}" align="center">{naamregel.WOONPLAATS}</td>
<!-- END naamregel -->
</table>
Het resultaat is te zien op
http://www.diablo2forum.nl/naw.php
In
Code: Selecteer alles
$template->assign_vars(array(
'L_NAAM' => 'Naam',
'L_ADRES' => 'Adres',
'L_POSTCODE' => 'Postcode',
'L_WOONPLAATS' => 'Woonplaats')
gebruik ik tabelkoppen. Voor het gemak gebruik ik stringconstanten.
In
Code: Selecteer alles
$template->assign_block_vars('naamregel', array(
'ROW_COLOR' => $row_color,
'ROW_CLASS' => $row_class,
'NAAM' => $naam,
'ADRES' => $adres,
'POSTCODE' => $postcode,
'WOONPLAATS' => $woonplaats));
staat een stuk dat steeds herhaald wordt. Het staat ook in de while-lus die per gevonden regel in de SQL-tabel doorlopen wordt.
"naamregel" is een blokvariabele. In het .TPL bestand wordt het herhalende gedeelte geplaatst tussen <!-- BEGIN naamregel --> en <!-- END naamregel -->
Daartussen staan velden tussen accolades. De blokvariabele wordt daarbinnen gevolgd door een punt en een labelvariabele.
{naamregel.NAAM} is steeds de naam die gevonden wordt. Dat verandert natuurlijk per rij.