Simple Math
ExpressionEngine 1.x, ExpressionEngine 2
Back to this add-on's main page
View Other Add-ons From Laisvunas
Very simple question
Support Request
Paoloemme
|
Posted: 26 July 2012 01:04 PM |
|
|
|
Just purchased Simple math.
I need to print on my EE1.7 template a value as result of:
{field1} / {var2}
My attempts failed:
exp:simple_math calculate=”({var1} / {var2}) ” var1=“10” var2={Confezione} var2={prezzo}}
Can I have the correct syntax?
Thank you
Paolo, from Italy
|
|
|
Laisvunas
|
Posted: 26 July 2012 01:57 PM |
# 1
|
|
Developer
|
Hi Paolo,
Which EE tag outputs the values of variables {Confezione} and {prezzo}? You might forgot to add to that EE tag the parameter
parse="inward"
Also notice that in your code the tag exp:simple_math have two parameters “var2” and that the value of parameter “var2” is without quotes.
|
|
|
Paoloemme
|
Posted: 26 July 2012 04:23 PM |
# 2
|
|
|
{Confezione} and {prezzo} are two fields in wich I input numeric values.
I would like only to get result from {Confezione} / {prezzo} on a table cell.
I’m not able to place correctly the parameter tag you suggest: parse=“inward” simply because I am really unaware about the syntax. I didn’t find any reference about it in simply math example page.
Could you please write me a basic but complete syntax formula, tag or expression to get a result by dividing two fields?
I thank you so much.
|
|
|
Laisvunas
|
Posted: 26 July 2012 04:43 PM |
# 3
|
|
Developer
|
Are {Confezione} and {prezzo} fields of exp:channel:entries tag?
|
|
|
Paoloemme
|
Posted: 26 July 2012 04:55 PM |
# 4
|
|
|
yes, they are.
|
|
|
Laisvunas
|
Posted: 26 July 2012 05:07 PM |
# 5
|
|
Developer
|
Add
parse="inward"
to exp:channel:entries tag.
|
|
|
Paoloemme
|
Posted: 26 July 2012 05:14 PM |
# 6
|
|
|
I tried.
But syntax is wrong for shure:
{exp:weblog:entries weblog=“prezzi” parse=“inward” orderby=“date” limit=“10” }
<th scope=“col”>{username}</th>
<th scope=“col”>{title}</th>
<th scope=“col”>{Data}</th>
<th scope=“col”>{Confezione}</th>
<th scope=“col”>{prezzo}</th>
<th scope=“col”>{{calculate=”{var1} / {var2}) ” var1=“10” parse=“inward” =”{Confezione}” var2=”{prezzo}”}</th>
</tr>
{/exp:weblog:entries}
Can you correct it?
|
|
|
Paoloemme
|
Posted: 26 July 2012 05:18 PM |
# 7
|
|
|
please, forget me.
Here what I really wrote:
{exp:weblog:entries weblog=“prezzi” parse=“inward” orderby=“date” limit=“100” }
<th scope=“col”>{username}</th>
<th scope=“col”>{title}</th>
<th scope=“col”>{Data}</th>
<th scope=“col”>{Confezione}</th>
<th scope=“col”>{prezzo}</th>
<th scope=“col”>{{calculate=”{var1} / {var2}) ” var1=”{Confezione}” var2=”{prezzo}”}</th>
</tr>
{/exp:weblog:entries}
|
|
|
Laisvunas
|
Posted: 26 July 2012 05:19 PM |
# 8
|
|
Developer
|
Try this code:
{exp:weblog:entries weblog="prezzi" parse="inward" orderby="date" limit="10"} <th scope=“col”>{username}</th> <th scope=“col”>{title}</th> <th scope=“col”>{Data}</th> <th scope=“col”>{Confezione}</th> <th scope=“col”>{prezzo}</th> <th scope=“col”>{exp:simple_math calculate="{var1} / {var2}" var1="{Confezione}" var2="{prezzo}"}</th> </tr> {/exp:weblog:entries}
|
|
|
Paoloemme
|
Posted: 26 July 2012 05:25 PM |
# 9
|
|
|
No data were displayed.
|
|
|
Paoloemme
|
Posted: 26 July 2012 05:29 PM |
# 10
|
|
|
I mean: no data on the calculated column only , of course.
|
|
|
Laisvunas
|
Posted: 26 July 2012 05:30 PM |
# 11
|
|
Developer
|
Post URL of your template.
|
|
|
Paoloemme
|
Posted: 26 July 2012 05:33 PM |
# 12
|
|
|
http://www.igppachino.it/index.php/prezzi/
|
|
|
Laisvunas
|
Posted: 26 July 2012 05:40 PM |
# 13
|
|
Developer
|
Hi,
The code does not work because of number formatting: it should be not 0,5 but 0.5 and not 1,10 but 1.10
After doing calculation you can reformat the number as you wish.
|
|
|
Paoloemme
|
Posted: 26 July 2012 05:48 PM |
# 14
|
|
|
Really sorry, but after modifying entries the result was the same:
http://www.igppachino.it/index.php/prezzi/
|
|
|
Laisvunas
|
Posted: 26 July 2012 05:53 PM |
# 15
|
|
Developer
|
Try this code in your template and see if it works:
{exp:simple_math calculate="{var1} / {var2}" var1="0.5" var2="1.10" invalid_input="alert"}
|
|
|