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

Indiziertes Array in Smarty nutzen

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


Joined: 11 Sep 2004
Posts: 3

PostPosted: Thu Mar 03, 2005 12:47 pm    Post subject: Indiziertes Array in Smarty nutzen Reply with quote

Hi,

wie kann ich ein indiziertes Array in Smarty nutzen bzw. zuweisen?

Ich habe folgendes vor:

php:
Code:

$sel = array(0 => '', 1 => 'selected="selected"');
$smarty->assign($sel);


Template:
Code:

<select name="bla">
  <option value="0" {$sel[0]}>blub</option>
  <option value="1" {$sel[1]}>foo</option> 
</select>


Problem: $sel steht in Smarty garnicht zur Verfügung, zumindest nicht über den obigen Aufruf.

Mit assoziativen Arrays klappt das natürlich problemlos, doch diese möchte ich in diesem Fall nicht nutzen.


cu
Back to top
View user's profile Send private message
coach
Smarty Regular


Joined: 03 Jun 2004
Posts: 65

PostPosted: Thu Mar 03, 2005 6:07 pm    Post subject: Reply with quote

Hi,

laut
http://smarty.php.net/manual/de/language.variables.php#language.assigned.variables

sollte es mit dem Punkt funzen.

Du kannst übrigens einmal den Debug-Modus anstellen:
Code:

$my_smarty->debugging = true;

und dann genau schauen, welche Variablen Smarty kennen müßte.

Coach
Back to top
View user's profile Send private message
ZakMc
Smarty Pro


Joined: 04 Oct 2004
Posts: 182

PostPosted: Mon Mar 07, 2005 10:30 am    Post subject: Reply with quote

das assign ist doch schon falsch, woher weiss smarty denn das das zugewiesene array im template $sel heissen soll.

es muss $smarty->assign("sel", $sel); heissen.

ansonsten sollte es richtig sein.

Wäre es nicht leiter wenn du das dropdown von smarty komplett zusammenbauen lässt mit einer section, bevor du alle möglichkeiten per hand einträgst???!!
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