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

Dynamische Includes

 
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
gansta
Smarty n00b


Joined: 29 Mar 2015
Posts: 4

PostPosted: Sun Mar 29, 2015 11:30 am    Post subject: Dynamische Includes Reply with quote

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
View user's profile Send private message
Grizzly
Smarty Pro


Joined: 15 Apr 2011
Posts: 172
Location: Germany

PostPosted: Mon Mar 30, 2015 7:02 am    Post subject: Reply with quote

Hey,

ich verstehe nicht genau, was du damit erreichen willst!?
Back to top
View user's profile Send private message Visit poster's website
gansta
Smarty n00b


Joined: 29 Mar 2015
Posts: 4

PostPosted: Mon Mar 30, 2015 7:07 am    Post subject: Reply with quote

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
View user's profile Send private message
Grizzly
Smarty Pro


Joined: 15 Apr 2011
Posts: 172
Location: Germany

PostPosted: Mon Mar 30, 2015 1:54 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
U.Tews
Administrator


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

PostPosted: Mon Mar 30, 2015 8:59 pm    Post subject: Reply with quote

Dies ist ein doppelter Eintrag.
Siehe http://www.smarty.net/forums/viewtopic.php?t=25478

Bitte ein Problem nur 1 mal posten.
Back to top
View user's profile Send private message
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