Accumulerende templates?
Problemet: Når en dynamisk block forefindes indeni en anden dynamisk block (i separate filer selvfølgelig) accumuleres det parsede data fra den inderste dynamiske block.Spørgsmålet: Hvordan kan scriptet laves så det ikke accumulerer dataene?
Følgende eksempel illustrerer problemet:
--- (BEGIN test.php) ---
<?php
include(\'class.FastTemplate.php3\');
$tpl = new FastTemplate(\"./\");
$tpl->no_strict();
function Show()
{
global $tpl;
$tpl->define_dynamic(\"main_dyn\", \"main\");
$tpl->define_dynamic(\"table_dyn\", \"table\");
for ($Anumber = 0; $Anumber < 2; $Anumber++) {
$tpl->assign(\"Anumber\", $Anumber);
$Start = $Anumber * 100;
for ($Bnumber = $Start; $Bnumber < $Start + 2; $Bnumber++) {
$tpl->assign(\"Bnumber\", $Bnumber);
$tpl->parse(\"table_dyn_rows\", \".table_dyn\");
}
$tpl->parse(\"table_screen\", \"table\");
$tpl->parse(\"main_dyn_rows\", \".main_dyn\");
}
}
$tpl->define(
array(
\"main\" => \"main.html\",
\"table\" => \"table.html\",
)
);
Show();
$tpl->parse(\"\", \"main\");
$tpl->FastPrint();
--- (END test.php) ---
--- (BEGIN main.html) ---
<html>
<head>
</head>
<body>
<h1>Test</h1>
<!-- BEGIN DYNAMIC BLOCK: main_dyn -->
A:{Anumber}
<br>
{table_screen}
<br><br>
<!-- END DYNAMIC BLOCK: main_dyn -->
Skulle være:<br>
A:0<br>
B:0<br>
B:1<br>
<br><br>
A:1<br>
B:100<br>
B:101<br>
</body>
</html>
--- (END main.html) ---
--- (BEGIN table.html) ---
<!-- BEGIN DYNAMIC BLOCK: table_dyn -->
B:{Bnumber}
<br>
<!-- END DYNAMIC BLOCK: table_dyn -->
--- (END table.html) ---
--- (BEGIN output)---
Test
A:0
B:0
B:1
A:1
B:0
B:1
B:100
B:101
Skulle være:
A:0
B:0
B:1
A:1
B:100
B:101
---(END output)---