|
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 |
Paykoman Smarty Rookie
Joined: 07 May 2011 Posts: 34
|
Posted: Sat Jun 08, 2013 6:59 am Post subject: Positionieren von .tpl files |
|
|
Hallo,
mein gestriger Beitrag war wohl etwas groß darum versuch ich es heute mal in einer verkürzten Form!
Und zwar habe ich mal einen neuen Test gemacht:
Code: |
$smarty->assign("hook_header", include 'modules/gfw/headbar/headbar.tpl', true);
|
Ich hatte gehofft das Template so in einer Variable speichern zu können um dann im header.tpl zu bestimmen wo das eingebettete .tpl angezeigt werden soll. Leider gibt Smarty dies einfach ganz oben in Zeile #1 aus anstatt dort wo die Variable ist und es eigentlich hätte ausgegeben werden sollen!
Gibt es hier einen Trick um .tpl mit php einzubetten? Ich weiß man kann bei den Template-Dateien direkt ein Include einbauen, das setzt aber voraus das die einzubindende Datei immer vorhanden ist und das man von Anfang an alle Dateien kennt die eingebunden werden sollen, dies entspricht aber nun nicht meinem Modulbasiertem Vorhaben =(
Ich hoffe mir wird Jemand helfen.
MFG: Paykoman |
|
Back to top |
|
Fahrstuhllicht Smarty Rookie
Joined: 10 Jun 2013 Posts: 15 Location: Berlin
|
Posted: Tue Jun 11, 2013 6:26 am Post subject: |
|
|
Ich bin zwar selbst noch Anfänger aber versuch doch mal:
Ich habe mir eine Master.tpl erstellt, die {$header} enthält
und in der index.php wie folgt deklariert:
Code: | $smarty->assign('header',$smarty->fetch('header.tpl') |
|
|
Back to top |
|
Paykoman Smarty Rookie
Joined: 07 May 2011 Posts: 34
|
Posted: Sun Jun 16, 2013 12:27 pm Post subject: |
|
|
So habe jetzt die Umbauten fertig und konnte dank deines Tipps das Problem nun auch lösen. Wow vielen dank dafür! =)
An der Struktur musste ich nichts verändern, mein hook-system ist so aufgebaut das es eine .php Datei aufruft diese .php Datei wiederum spricht smarty an und übergibt alles an die .tpl datei hier beispiel:
Code: |
class block_logo
{
function getlogo()
{
$smarty = new Smarty;
$smarty->force_compile = force_compile;
$smarty->cache_lifetime = cache_lifetime;
$smarty->debugging = debugging;
$smarty->caching = caching;
$smarty->assign('logolnk', "http://".$_SERVER['HTTP_HOST'], true);
$return = $smarty->fetch('app/templates/default/modules/block_logo/block_logo'.tpl_ext);
return $return;
}
}
$logomod = new block_logo();
add_hook( 'header', array(&$logomod,'getlogo') );
|
Und ich habe hier einfach statt §smarty->display wie man sieht jetzt $smarty->fetch stehen und schwupp die wupps wird das template dort angezeigt wo es auch angezeigt werden sollte!
Noch mal danke=)
MFG: Pay
PS: der code schnippsel oben war nur zum Testen *g* |
|
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
|