Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Dedicated server web hosting provided by Guru-host.eu.
Alternative Template Datei

 
Post new topic   Reply to topic    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
eazytrader
Smarty Rookie


Joined: 16 Jul 2010
Posts: 31

PostPosted: Sat Jul 16, 2011 8:56 am    Post subject: Alternative Template Datei Reply with quote

Hallo,

$smarty->template_dir ist bei mir ein Array.
Sodass eine Templatedatei die im aktuellen Template nicht vorhanden ist, im Standard Template gesucht wird.
Das klappt auch Prima.

Nun möchte ich aber innerhalb eines Templates, eine Alternative Templatedatei laden. Das mache ich bisher so:

Code:
  if(is_file(DIR_FS_SHOP . 'templates/' . SMARTY_CURRENT_TEMPLATE_DIR . '/p_info_' . $_GET['pid'] . '.tpl')){
    $smarty->display('p_info_' . $_GET['pid'] . '.tpl');
  }else{
    $smarty->display('p_info.tpl');
  }


Leider geht so das o.g. Konzept verloren.
Da ja immer nur im aktuellen Template Verzeichnis gesucht wird.
Kennt dafür jemand eine dynamischere Lösung? Sodass man auch hier die Verzeichnisse der Reihe nach absuchen kann, wie Smarty das ja von haus aus macht?

Gruß und Danke.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4178
Location: Hamburg / Germany

PostPosted: Sat Jul 16, 2011 9:27 am    Post subject: Reply with quote

Code:
if($smarty->templateExists('p_info_' . $_GET['pid'] . '.tpl')){
    $smarty->display('p_info_' . $_GET['pid'] . '.tpl');
  }else{
    $smarty->display('p_info.tpl');
  }
Back to top
View user's profile Send private message
eazytrader
Smarty Rookie


Joined: 16 Jul 2010
Posts: 31

PostPosted: Sat Jul 16, 2011 5:43 pm    Post subject: Reply with quote

Dank Dir Uwe!
Das funktioniert prima.

Ich hätte noch eine Frage und möchte deshalb kein neues Thema erstellen.

Wenn ich Caching aktiviere funktionieren $_GET Parameter nicht mehr.
Bzw. Sie werden nicht mehr berücksichtigt.

Wo liegt denn der Unterschied zwischen dem compile_dir und dem cache_dir.
In beide Ordner werden ja die Dateien jeweils Zwischengespeichert.

Gruß
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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