Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Eine php datei in ein Template einbinden?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
Demonking
Smarty Rookie


Joined: 05 Jun 2006
Posts: 7

PostPosted: Tue Jan 15, 2013 11:27 pm    Post subject: Eine php datei in ein Template einbinden? Reply with quote

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
View user's profile Send private message
tron2k
Guest





PostPosted: Wed Jan 16, 2013 2:37 am    Post subject: Reply with quote

Du kannst auch dir auch ein Template schreiben, von dem die anderen Templates erben. Dann kann sich jede Seite komplett selbst ausgeben.

Das ist alles unter

http://www.smarty.net/docs/en/advanced.features.template.inheritance.tpl

beschrieben.
Back to top
Demonking
Smarty Rookie


Joined: 05 Jun 2006
Posts: 7

PostPosted: Wed Jan 16, 2013 6:45 am    Post subject: Reply with quote

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. Wink

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
View user's profile Send private message
klappi
Guest





PostPosted: Wed Jan 16, 2013 5:41 pm    Post subject: Reply with quote

Demonking wrote:

Glaube mir ist nachdem Schlaf etwas eingefallen. Wink
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
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP