|
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 |
rehman Smarty n00b
Joined: 16 May 2019 Posts: 1
|
Posted: Thu May 16, 2019 10:27 am Post subject: Problem bei der Berechnung |
|
|
Ich habe Problem bei der Berechnung wegen Komma und Punkt.
bei einem Variable (Gesamtsumme) möchte ich 23,50 Euro addieren.
z.B 1000+23,50 = 1.023,50 das muss Ergebnis und format sein. Da Smarty kein Komma akzeptiert. schreibe ich 23.50.
Beispiel:
{assign var = "amount" value =$variable|replace:',':'.'}
{math equation = "x+y" x=$amount y=23.50 format="%.2f"}
als Ergebnis addiert der Variable 1000+23.500 statt 23,50 und gib 24.500 Euro
Es muss so sein 1.000+23,50= 1.023,50 |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat May 18, 2019 11:17 am Post subject: |
|
|
Either do your calculation before calling Smarty, or don't pass pre-formatted values to Smarty.
Preferable both. Totals calculation is part of business logic of your app and should be done in app, not in template, and formatting should be done in the template, not in the app. |
|
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
|