|
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 |
gansta Smarty n00b
Joined: 29 Mar 2015 Posts: 4
|
Posted: Sun Mar 29, 2015 11:30 am Post subject: Dynamische Includes |
|
|
Hallo allerseits,
ich würde Includes gerne dynamisch erzeugen und komme nicht weiter.
Mein PHP sieht bspw so aus:
Code: | $selections = array();
$selections['period'] = array('type'=>'month');
$selections['project'] = array();
$selections['entity'] = array('selected'=>'1', 'filter'=>'Core');
$smarty->assign("selections", $selections);
... |
Als Ergebnis in Smarty hätte ich für dieses Beispiel gerne:
Code: | {include file="includes/period_selection.html" type="month"}
{include file="includes/project_selection.html"}
{include file="includes/entity_selection.html" selected='1' filter='Core'} |
Wie kann ich das erreichen?
Wäre schön, wenn Ihr mir helfen könntet
LG, Gansta |
|
Back to top |
|
Grizzly Smarty Pro
Joined: 15 Apr 2011 Posts: 172 Location: Germany
|
Posted: Mon Mar 30, 2015 7:02 am Post subject: |
|
|
Hey,
ich verstehe nicht genau, was du damit erreichen willst!? |
|
Back to top |
|
gansta Smarty n00b
Joined: 29 Mar 2015 Posts: 4
|
Posted: Mon Mar 30, 2015 7:07 am Post subject: |
|
|
Hallo,
es geht darum in der PHP Logik zu entscheiden welche Filter im Template eingebunden werden.
Ist in der Logik einer Seite bspw der Array Index $selections['project'] nicht gesetzt, wird dort der Projektfilter nicht angezeigt.
Verständlich? |
|
Back to top |
|
Grizzly Smarty Pro
Joined: 15 Apr 2011 Posts: 172 Location: Germany
|
Posted: Mon Mar 30, 2015 1:54 pm Post subject: |
|
|
Du kannst doch prinzipiell jede beliebige Variable an das "include" übergeben.
Dann musst du halt im Template welches du inkludierst mit
Code: | {if isset($DeineArray["DeineVariable"])}
//Deine Logik hier, wenn gesetzt
{/if}
|
überprüfen, ob die Variable gesetzt ist.
Siehe hier z. B.: http://www.smarty.net/docs/en/language.function.include.tpl#idp35758448 |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
|
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
|