Andislack
25-04-2003, 21:24
hi!
ich bin gerade dabei mir eine allgemeine klasse für meine templates zu schreiben.
die allgemeine klasse funktioniert auch, aber mit der an die ich vererbt habe wird nichts angefangen!?
also mein main.tpl sieht so aus nur zum verständnis
<!--main.tpl-->
<html>
<head>
{TITEL}
{SCRIPTS}
{CSS}
</head>
<body>
<table width='100%'>
<tr>
<td colspan='2' height='150'>{LOGO}</td>
</tr>
<tr>
<td width='150'>{MENUE}</td>
<td width='*' valign='top'>{MAINLOGO}</td>
</tr>
</table>
</body>
</html>
</--main.tpl-->
wie gesagt, die erste klasse wird einwandfrei ausgegeben (für {LOGO} und {MENUE}), aber die andere, in der ich die inhalte von {MAINLOGO}, {TITEL}, {SCRIPTS} und {MENUSCRIPT}" hinzufüge, wird völlig unberücksichtigt gelassen.
ob ich im mom am ende
$tpl = new ersatz($tpl);
oder
$tpl = new maintpl($tpl);
aufrufe, es wird immer das gleiche ausgegeben...beides ohne die komplette class ersatz.
hier mal meine classen...
<?php
include "../../template/class.FastTemplate.php3";
//Allgemeine Template class maintpl definieren, die auf jeder Seite
//immer gleich angezeigt werden soll
class maintpl {
var $tpl;
function maintpl($tpl) {
$this->tpl = $tpl;
$this->tpl = $tpl = new FastTemplate(".");
$this->tpl = $tpl->define(array( css => "../tpl/mbmcss.tpl",
logo => "../tpl/logo.tpl",
menue => "../tpl/menu.tpl",
main => "../tpl/main.tpl"));
$this->tpl = $tpl->parse("{CSS}", "css");
$this->tpl = $tpl->parse("{LOGO}", "logo");
$this->tpl = $tpl->parse("{MENUE}", "menue");
$this->tpl = $tpl->parse("{MAIN}", "main");
$this->tpl = $tpl->FastPrint("{MAIN}");
}
}//maintpl
//Ende Allgemeine class maintpl
//Definieren der class ersatz, die jeweils den Inhalt von {MAINLOGO} beinhaltet
class ersatz extends maintpl {
function template(){
$this->tpl = $tpl->define(array( titel => "../tpl/titel.tpl",
mainlogo => "../ersatzteile/ersatzteile.tpl",
menuscript => "../../scripts/menuscript.tpl",
scripts => "../../scripts/none.tpl"));
$this->tpl = $tpl->parse("{TITEL}", "titel");
$this->tpl = $tpl->parse("{MAINLOGO}", "mainlogo");
$this->tpl = $tpl->parse("{SCRIPTS}", "scripts");
$this->tpl = $tpl->parse("{MENUSCRIPT}", "menuscript");
}
}//Ende class ersatz
//Aufruf einer Instanz von der class ersatz
//und damit auch maintpl um {MAINLOGO} zu füllen
$tpl = new ersatz($tpl);
?>
Ich hab mit OOP erst angefangen... :cool:
wär nett, wenn sich das mal jemand ansehen könnte
schönes woe gruss andi
ich bin gerade dabei mir eine allgemeine klasse für meine templates zu schreiben.
die allgemeine klasse funktioniert auch, aber mit der an die ich vererbt habe wird nichts angefangen!?
also mein main.tpl sieht so aus nur zum verständnis
<!--main.tpl-->
<html>
<head>
{TITEL}
{SCRIPTS}
{CSS}
</head>
<body>
<table width='100%'>
<tr>
<td colspan='2' height='150'>{LOGO}</td>
</tr>
<tr>
<td width='150'>{MENUE}</td>
<td width='*' valign='top'>{MAINLOGO}</td>
</tr>
</table>
</body>
</html>
</--main.tpl-->
wie gesagt, die erste klasse wird einwandfrei ausgegeben (für {LOGO} und {MENUE}), aber die andere, in der ich die inhalte von {MAINLOGO}, {TITEL}, {SCRIPTS} und {MENUSCRIPT}" hinzufüge, wird völlig unberücksichtigt gelassen.
ob ich im mom am ende
$tpl = new ersatz($tpl);
oder
$tpl = new maintpl($tpl);
aufrufe, es wird immer das gleiche ausgegeben...beides ohne die komplette class ersatz.
hier mal meine classen...
<?php
include "../../template/class.FastTemplate.php3";
//Allgemeine Template class maintpl definieren, die auf jeder Seite
//immer gleich angezeigt werden soll
class maintpl {
var $tpl;
function maintpl($tpl) {
$this->tpl = $tpl;
$this->tpl = $tpl = new FastTemplate(".");
$this->tpl = $tpl->define(array( css => "../tpl/mbmcss.tpl",
logo => "../tpl/logo.tpl",
menue => "../tpl/menu.tpl",
main => "../tpl/main.tpl"));
$this->tpl = $tpl->parse("{CSS}", "css");
$this->tpl = $tpl->parse("{LOGO}", "logo");
$this->tpl = $tpl->parse("{MENUE}", "menue");
$this->tpl = $tpl->parse("{MAIN}", "main");
$this->tpl = $tpl->FastPrint("{MAIN}");
}
}//maintpl
//Ende Allgemeine class maintpl
//Definieren der class ersatz, die jeweils den Inhalt von {MAINLOGO} beinhaltet
class ersatz extends maintpl {
function template(){
$this->tpl = $tpl->define(array( titel => "../tpl/titel.tpl",
mainlogo => "../ersatzteile/ersatzteile.tpl",
menuscript => "../../scripts/menuscript.tpl",
scripts => "../../scripts/none.tpl"));
$this->tpl = $tpl->parse("{TITEL}", "titel");
$this->tpl = $tpl->parse("{MAINLOGO}", "mainlogo");
$this->tpl = $tpl->parse("{SCRIPTS}", "scripts");
$this->tpl = $tpl->parse("{MENUSCRIPT}", "menuscript");
}
}//Ende class ersatz
//Aufruf einer Instanz von der class ersatz
//und damit auch maintpl um {MAINLOGO} zu füllen
$tpl = new ersatz($tpl);
?>
Ich hab mit OOP erst angefangen... :cool:
wär nett, wenn sich das mal jemand ansehen könnte
schönes woe gruss andi