FastTemplate duplicate parse?
Ik weet niet of jullie bekend zijn met FastTemplate, maar ik zit met een (klein) probleempje.
Ik heb FastTemplate gedownload, wat geprobeerd, en even dynamic_example.php iets aangepast. Het probleem is, dat ik een dubbele output krijg, dat wil zeggen, ik krijg: 1s 2s 3s, en dan dit weer een keer opnieuw. Ik wil dit maar één keer, maar dit lukt me niet. Ik heb nu:
Dynamic.tpl:
Iemand een idee?
Output:Dus 2x het hele zooitje.
Ik heb FastTemplate gedownload, wat geprobeerd, en even dynamic_example.php iets aangepast. Het probleem is, dat ik een dubbele output krijg, dat wil zeggen, ik krijg: 1s 2s 3s, en dan dit weer een keer opnieuw. Ik wil dit maar één keer, maar dit lukt me niet. Ik heb nu:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?
include("class.FastTemplate.php");
$tpl = new FastTemplate("./templates");
$start = $tpl->utime();
$tpl->define(
array(
main => "main.tpl",
table => "dynamic.tpl"
)
);
$tpl->define_dynamic ( "row", "table" );
$tpl->assign( array( TITLE => "FastTemplate Dynamic Test") );
for ($n=1; $n <= 3; $n++) {
$Number = $n;
$BigNum = $Number*10;
$tpl->assign(
array(
NUMBER => $Number,
BIG_NUMBER => $BigNum
)
);
$tpl->parse(ROW,".row");
$tpl->define_dynamic ( "row2", "table" );
for ($a=1; $a <= 1; $a++){
$tpl->assign(
array(
GOOGLE => 's',
)
);
$tpl->parse(ROW,".row2");
}
}
$tpl->parse(MAIN, array("table","main"));
$tpl->FastPrint();
$end = $tpl->utime();
$run = $end - $start;
echo "Runtime [$run] seconds<BR>\n";
exit;
?>
include("class.FastTemplate.php");
$tpl = new FastTemplate("./templates");
$start = $tpl->utime();
$tpl->define(
array(
main => "main.tpl",
table => "dynamic.tpl"
)
);
$tpl->define_dynamic ( "row", "table" );
$tpl->assign( array( TITLE => "FastTemplate Dynamic Test") );
for ($n=1; $n <= 3; $n++) {
$Number = $n;
$BigNum = $Number*10;
$tpl->assign(
array(
NUMBER => $Number,
BIG_NUMBER => $BigNum
)
);
$tpl->parse(ROW,".row");
$tpl->define_dynamic ( "row2", "table" );
for ($a=1; $a <= 1; $a++){
$tpl->assign(
array(
GOOGLE => 's',
)
);
$tpl->parse(ROW,".row2");
}
}
$tpl->parse(MAIN, array("table","main"));
$tpl->FastPrint();
$end = $tpl->utime();
$run = $end - $start;
echo "Runtime [$run] seconds<BR>\n";
exit;
?>
Dynamic.tpl:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!-- NAME: dynamic.tpl -->
<table>
<!-- BEGIN DYNAMIC BLOCK: row -->
<tr>
<td>{NUMBER}</td>
<td>{BIG_NUMBER}</td>
</tr>
<!-- END DYNAMIC BLOCK: row -->
<!-- BEGIN DYNAMIC BLOCK: row2 -->
<tr>
<td>{GOOGLE}</td>
</tr>
<!-- END DYNAMIC BLOCK: row2 -->
</table>
<!-- END: dynamic.tpl -->
<table>
<!-- BEGIN DYNAMIC BLOCK: row -->
<tr>
<td>{NUMBER}</td>
<td>{BIG_NUMBER}</td>
</tr>
<!-- END DYNAMIC BLOCK: row -->
<!-- BEGIN DYNAMIC BLOCK: row2 -->
<tr>
<td>{GOOGLE}</td>
</tr>
<!-- END DYNAMIC BLOCK: row2 -->
</table>
<!-- END: dynamic.tpl -->
Iemand een idee?
Output:Dus 2x het hele zooitje.
Gewijzigd op 11/03/2005 15:15:00 door Mark PHP
Gesponsorde koppelingen:
for ($n=1; $n <= 3; $n++) {
doe dan is
for ($n=1; $n < 3; $n++) {
ik weet niet maar...
doe dan is
for ($n=1; $n < 3; $n++) {
ik weet niet maar...
Han:
Nee helaas. Ik heb al veel geprobeerd, ik ben niet iemand die snel zegt t lukt niet. Maar helaas werkt dit niet zoals ik graag wil:(for ($n=1; $n <= 3; $n++) {
doe dan is
for ($n=1; $n < 3; $n++) {
ik weet niet maar...
doe dan is
for ($n=1; $n < 3; $n++) {
ik weet niet maar...
Ik heb besloten FastTemplate links te laten liggen, bij TemplatePower lukt alles wel makkelijk. Ik heb besloten FastTemplate, waarvan de code toch wat haperde, maar te vervangen door een goed gecodeerde:)



