Crew algemeen |
|
je overschrijft de variabele altijd.
Je moet 1 block aanm maken in je template:
<!-- START BLOCK : blockname --><tr>
<td style="width: 80%;"><div class="link"><a class="link" href="{link}" title="'.$xml_sleutel[$xml_index['TITEL'][$i]]['value'].'" onclick="window.open(this.href,\'_blank\');return false;">{titel}</a></div></td>
<td style="width: 20%;"><div class="content">{zender}</div></td>
</tr>
<!-- END BLOCK : blockname -->
<!-- START BLOCK : blockname --><tr> <td style="width: 80%;"><div class="link"><a class="link" href="{link}" title="'.$xml_sleutel[$xml_index['TITEL'][$i]]['value'].'" onclick="window.open(this.href,\'_blank\');return false;">{titel}</a></div></td> <td style="width: 20%;"><div class="content">{zender}</div></td> </tr> <!-- END BLOCK : blockname -->
nadien roep je x aantal keer het block op, en vervang je de waardes altijd:
<?php
$tpl->newBlock('blockname');
$tpl->assign(array(
'link' => $xml_sleutel[$xml_index['LINK'][$i]]['value'],
'titel' => afkorten($xml_sleutel[$xml_index['TITEL'][$i]]['value'],30),
'zender' => $xml_sleutel[$xml_index['ZENDER'][$i]]['value']
));
?>
<?php $tpl->newBlock('blockname'); 'link' => $xml_sleutel[$xml_index['LINK'][$i]]['value'], 'titel' => afkorten($xml_sleutel[$xml_index['TITEL'][$i]]['value'],30), 'zender' => $xml_sleutel[$xml_index['ZENDER'][$i]]['value'] )); ?>
uitgewerkt:
tplfile.tpl:
<!-- START BLOCK : start -->
<table cellpadding="0" cellspacing="0" style="width: 100%;">
<!-- END BLOCK : start -->
<!-- START BLOCK : blockname -->
<tr>
<td style="width: 80%;"><div class="link"><a class="link" href="{link}" title="'.$xml_sleutel[$xml_index['TITEL'][$i]]['value'].'" onclick="window.open(this.href,\'_blank\');return false;">{titel}</a></div></td>
<td style="width: 20%;"><div class="content">{zender}</div></td>
</tr>
<!-- END BLOCK : blockname -->
<!-- START BLOCK : end -->
</table>
<!-- END BLOCK : end -->
<!-- START BLOCK : start --> <table cellpadding="0" cellspacing="0" style="width: 100%;"> <!-- END BLOCK : start --> <!-- START BLOCK : blockname --> <tr> <td style="width: 80%;"><div class="link"><a class="link" href="{link}" title="'.$xml_sleutel[$xml_index['TITEL'][$i]]['value'].'" onclick="window.open(this.href,\'_blank\');return false;">{titel}</a></div></td> <td style="width: 20%;"><div class="content">{zender}</div></td> </tr> <!-- END BLOCK : blockname --> <!-- START BLOCK : end --> </table>
phpfile.php:
<?php
function Parse_FilmTotaal($nieuwsfeed)
{
//Haal het bestand op
$xml_feed = file_get_contents($nieuwsfeed);
//Een XML phraser aanmaken
$xml_praser = xml_parser_create();
//Verwerking
xml_parse_into_struct($xml_praser,$xml_feed,$xml_sleutel,$xml_index);
xml_parser_free($xml_praser);
$tpl->newBlock('start');
for($i = 0; !empty($xml_index['TITEL'][$i]); $i++)
{
$tpl->newBlock('blockname');
$tpl->assign(array(
'link' => $xml_sleutel[$xml_index['LINK'][$i]]['value'],
'titel' => afkorten($xml_sleutel[$xml_index['TITEL'][$i]]['value'],30),
'zender' => $xml_sleutel[$xml_index['ZENDER'][$i]]['value']
));
}
$tpl->newBlock('end');
}
Parse_FilmTotaal('http://www.filmtotaal.nl/trackers/xml/filmsoptv.xml');
?>
<?php function Parse_FilmTotaal($nieuwsfeed) { //Haal het bestand op //Een XML phraser aanmaken //Verwerking $tpl->newBlock('start'); for($i = 0; !empty($xml_index['TITEL'][$i]); $i++) { $tpl->newBlock('blockname'); 'link' => $xml_sleutel[$xml_index['LINK'][$i]]['value'], 'titel' => afkorten($xml_sleutel[$xml_index['TITEL'][$i]]['value'],30), 'zender' => $xml_sleutel[$xml_index['ZENDER'][$i]]['value'] )); } $tpl->newBlock('end'); } Parse_FilmTotaal('http://www.filmtotaal.nl/trackers/xml/filmsoptv.xml'); ?>
zoiets zou moeten werken... |