Mam problem z parserem szablonów. Polega on na tym że includowany plik pojawia się na samej górze strony, a nie w miejscu gdzie chce. Próbowałem też pisac własne funkcje includujące pliki, ale wtedy nie moge przekazac do includowanego pliku zmiennej z $_GET'a czy innej tablicy superglobalnej. (Poprostu nie wyświetla mi wartości zmiennej $xp przekazanej przez pasek adresu #
http://localhost/?url=inc.php&xp=JakasZmienna #) Mam również problem z utworzeniem subsekcji. Czy moglibyście w jakiś sposób nakierować mnie na jakieś konkretne rozwiązania?? (przykłady i adaptacje załączonej klasy mile widziane :) ) Z góry dziękuje!
index.tpl
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"> <td align="center" valign="top"> <table width="700" border="0" cellpadding="4" cellspacing="10"> <td colspan="3" id="table"><div align="right">{LOGO}
</div></td> <td width="20%" valign="top" id="table">{MENU1}
</td> <td width="60%" height="300" valign="top" id="table">{TRESC}
</td> <td height="20%" valign="top" id="table">{MENU2}
</td> <td colspan="3" align="center" id="table">{STOPKA}
<br><b>{CZAS}
</b></td>
template.class.php
<?php
class TemplateSTCMS {
public $TemplateSTCMS;
public $DaneSTCMS;
public $ParsedSTCMS;
public function __construct( $name ){
}else{
echo\"Plik szablonu <b>$name</b> nie instieje\";
}
}else{
echo \"Nie podano nazwy szablonu!\"; }
}
public function parse( ){
return $this -> ParsedSTCMS
= preg_replace('/{([^}]+)}/e', '$this -> DaneSTCMS[\"1\"]', $this -> TemplateSTCMS
); }
public function show( ){
print $this -> ParsedSTCMS
; }
public function destruct__( ) {
unset( $this -> DaneSTCMS
); unset( $this -> TemplateSTCMS
); unset( $this -> ParsedSTCMS
); }
}
?>
test.php
<?php
include'template.class.php';
$tSTCMS = new TemplateSTCMS( 'index.tpl' );
$tSTCMS -> DaneSTCMS
= array( 'TYTUL' => 'tytul strony',
'TRESC' => 'srodek strony',
'MENU1' => 'menu 1 menu 1 menu 1',
'MENU2' => include \"$url\",
'STOPKA' => 'stopka stopka stopka',
'LOGO' => 'Bla bla bla'
);
$tSTCMS -> parse();
$tSTCMS -> show();
$tSTCMS -> destruct__();
?>
inc.php
<?php
?>