Plugin

Archived
Forum
(read-only)

Simple Math

ExpressionEngine 1.x, ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From Laisvunas

1 of 2
1
   

Very simple question

Support Request

Paoloemme
Paoloemme

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
# 1
Developer
Laisvunas

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
# 2
Paoloemme

{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
# 3
Developer
Laisvunas

Are {Confezione} and {prezzo} fields of exp:channel:entries tag?

Paoloemme
# 4
Paoloemme

yes, they are.

Laisvunas
# 5
Developer
Laisvunas

Add

parse="inward" 

to exp:channel:entries tag.

Paoloemme
# 6
Paoloemme

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
# 7
Paoloemme

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
# 8
Developer
Laisvunas

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
# 9
Paoloemme

No data were displayed.

Paoloemme
# 10
Paoloemme

I mean: no data on the calculated column only , of course.

Laisvunas
# 11
Developer
Laisvunas

Post URL of your template.

Paoloemme
# 12
Paoloemme

http://www.igppachino.it/index.php/prezzi/

Laisvunas
# 13
Developer
Laisvunas

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
# 14
Paoloemme

Really sorry, but after modifying entries the result was the same:

http://www.igppachino.it/index.php/prezzi/

Laisvunas
# 15
Developer
Laisvunas

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"
1 of 2
1