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

Wertzuweisung

 
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
Oliver
Smarty Rookie


Joined: 11 Nov 2014
Posts: 6

PostPosted: Thu Dec 08, 2016 8:15 am    Post subject: Wertzuweisung Reply with quote

Hallo zusammen,

ich möchte zwei Variablen Werte zu weisen, die in der Debug-Konsole angezeigt werden:


Mit dem Code
{assign var=netto value=$cart_total|replace:",":"."|floatval}
{assign var=zwischen value=$tax_data.tax_value.formated|replace:",":"."|floatval}
bekomme ich zwar einen Wert für netto, aber nicht für zwischen.

Kann mir bitte jemand sagen warum?

Danke und sonnige Grüße
Oliver
Back to top
View user's profile Send private message
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Thu Dec 08, 2016 9:16 am    Post subject: Reply with quote

Korrekter Weise sollte die Zuweisung mit var='netto' und var='zwischen' erfolgen.

In dem Console Screenshot ist $cart_total nicht zu sehen..
Back to top
View user's profile Send private message
Oliver
Smarty Rookie


Joined: 11 Nov 2014
Posts: 6

PostPosted: Thu Dec 08, 2016 9:29 am    Post subject: Reply with quote

ich habs auch schon mit Anführungszeichen versucht. Selbes Ergebnis.

Und ohne die Zuweisung gibt es die Variable gar nicht. Ich vermute, dass es irgendas mit dem Array zu tun hat. Hab ich das Array vielleicht nicht richtig angesprochen??

Vom Inhalt her stimmen $cart_total und $tax_data.tax_value.formated überein - sie unterscheiden sich nur in den Zahlen: also " #,## €". Und das erste ist eine normale Variable, das zweite ein Wert aus einem Array.
Back to top
View user's profile Send private message
Oliver
Smarty Rookie


Joined: 11 Nov 2014
Posts: 6

PostPosted: Thu Dec 08, 2016 9:43 am    Post subject: Reply with quote

noch was:

wenn ich nur {assign var=zwischen value=$tax_data.tax_value.formated} verwende, bekomme ich NULL als wert. Mit dem kompletten Befehl 0 (Zahl Null).

Daher vermute ich, dass der Zugriff auf das Array schon nicht stimmt. Aber warum und wieso, keine Ahnung.
Back to top
View user's profile Send private message
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Thu Dec 08, 2016 9:52 am    Post subject: Reply with quote

Nach dem Manual zu floatval ist der Wert 0 (Zahl), wenn das führende Zeichen nichtnumerisch ist. Wenn ich es richtig sehe, isses bei dir ein Leerzeichen.

Setz mal vor floatval noch einen strip Modifikator ein.

Und noch mal - es sollte

{assign var='zwischen' ...}

lauten Wink.
Back to top
View user's profile Send private message
Oliver
Smarty Rookie


Joined: 11 Nov 2014
Posts: 6

PostPosted: Thu Dec 08, 2016 9:57 am    Post subject: Reply with quote

ihr braucht euch keinen Kopf mehr zu machen: war ein I/O-Fehler (Idiot Operator). Ich habe die Variable zwei Zeilen zu früh abgefragt - die gibt es zu dem Zeitpunkt noch gar nicht.

Manchmal hilft es eben, wenn man sein Problem anderen erklärt.

Danke an alle.
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