|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Demonking Smarty Rookie
Joined: 05 Jun 2006 Posts: 7
|
Posted: Tue Jan 15, 2013 11:27 pm Post subject: Eine php datei in ein Template einbinden? |
|
|
Hallo Leute,
leider fiel mir keine bessere Überschrift ein, aber es sollte in etwa das aufzeigen was ich vorhabe.
Also meine index.tpl sieht folgendermassen aus:
Code: |
<body>
{include file='header.tpl'}
{include file='leftmenu.tpl'}
<div id="content">{include file="$contentdiv" }</div>
{include file="rightmenu.tpl"}
</body>
|
So das Problem ist nun, content kann alles sein, Gästebuch,Newssystem, ....
Die frage bleibt wie kriege ich das nun am elegantesten rein?
Ohne Smarty frage ich nach einer GET Variable und include dann die benötigte Datei.
Beispiel:
Code: | if(isset($_GET['show'])){
include $_GET['show']
else
include news.php |
Bei einer Lösung mit Smarty, habe ich nur die GET, aber kann die Php Datei nicht ohne weiteres einbinden.
Bei Smarty habe ich zur Zeit eine news.php und halt die nötigen Templates, aber ich muss ja die .php starten damit die .tpl auch mit Daten gefüllt wird.
Hätte jemand vllt ne anderen Lösungsansatz ausser include_php?
Gruß
Demonking |
|
Back to top |
|
tron2k Guest
|
|
Back to top |
|
Demonking Smarty Rookie
Joined: 05 Jun 2006 Posts: 7
|
Posted: Wed Jan 16, 2013 6:45 am Post subject: |
|
|
Hallo tron2k,
erstmal danke für deine Antwort, aber ich glaube nicht das es das ich wonach ich suche.
Glaube mir ist nachdem Schlaf etwas eingefallen.
Sagen wir mal ich habe
Code: | class News extends Smarty{} |
Dann brauche ich ja nur noch ne show Funktion zu schreiben,
Die sollte mir alle benötigten Daten holen assignen und dann als bsp
Code: | $news->display('news.tpl') |
|
|
Back to top |
|
klappi Guest
|
Posted: Wed Jan 16, 2013 5:41 pm Post subject: |
|
|
Demonking wrote: |
Glaube mir ist nachdem Schlaf etwas eingefallen.
Sagen wir mal ich habe
Code: | class News extends Smarty{} |
|
Versuche deine Objekte nicht so stark zu koppeln. Überlege noch mal ob du nicht ein MVC-Framework findest. Ich glaube für Silex gibt es ein ganz neues SmartyBundle. Ich habe Silex noch nicht benutzt habe aber bis jetzt den Eindruck das es ziemlich minimalistisch und leicht verständlich ist.
https://github.com/FractalizeR/Silex_SmartyServiceProvider |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|