[php] probleem met template bouwen

Pagina: 1
Acties:

  • BierPul
  • Registratie: Juni 2001
  • Laatst online: 31-08 22:20

BierPul

2 koffie graag

Topicstarter
Ik ben met een uitslagen mail programma bezig.

Op dit programma wil ikl templates kunnen laden.

In de templates hoef je alleen het woord [bericht] aan te geven en dan wordt de inhoud van het berocht in de template geparsed.

Alleen het gaat nied goed :+

Het lijkt dat ie de template in de template opend, wat volgend mij niet gek is als ik naar mn code kijk, maar zie nu na een middag peinsen ook niet direct de oplossing.

Ik gebruik de volgende 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
function doUitslag($str)   {
    global $uitslagen;
    global $datum;
    $str = str_replace("[uitslag]", $uitslagen, $str);  
    $str = str_replace("[datum]", $datum, $str);
return($str);
}

function bouwbericht($str)   {
    global $inhoud;
    $str = str_replace("[bericht]", $inhoud, $str);
echo($str);
}

#Deze data komt normaal uit de db
$uitslagen = "De volgende uitslag is gevallen 4,2,3,5,6,4";
$datum = "18-09-2002";


$text = doUitslag("Vandaag is het [datum] <br> [uitslag]");

$html_bestand = fopen("templates/nieuwsbrief_basic.html", "r");
$html= fread($html_bestand, 1000000);

$inhoud = $text;
$inhoud .= $html;

bouwbericht($inhoud); 

fclose ( $html_bestand);

Ja man


  • mkamonster
  • Registratie: Juni 2002
  • Laatst online: 16-08 16:04
Misschien moet van patTemplate gebruik gaan maken. Er is voor zover ik weet geen uitgebreidere template-parser/builder.

  • Janoz
  • Registratie: Oktober 2000
  • Laatst online: 28-08 12:00

Janoz

Moderator Devschuur®

!litemod

PHP:
1
2
3
4
$inhoud = $text; 
$inhoud .= $html; 

bouwbericht($inhoud);

moet zijn
PHP:
1
2
3
$inhoud = $text; 

bouwbericht($html);

en klaar...

Ken Thompson's famous line from V6 UNIX is equaly applicable to this post:
'You are not expected to understand this'