 |
Smarty
The discussions here are for Smarty, a template engine for the PHP programming language. Dedicated server web hosting provided by Guru-host.eu. |
| View previous topic :: View next topic |
| Author |
Message |
eazytrader Smarty Rookie
Joined: 16 Jul 2010 Posts: 31
|
Posted: Sat Jul 16, 2011 8:56 am Post subject: Alternative Template Datei |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 4178 Location: Hamburg / Germany
|
Posted: Sat Jul 16, 2011 9:27 am Post subject: |
|
|
| 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 |
|
eazytrader Smarty Rookie
Joined: 16 Jul 2010 Posts: 31
|
Posted: Sat Jul 16, 2011 5:43 pm Post subject: |
|
|
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 |
|
|
|
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
|