I use the powermail extension in my websites. Now I would like to have a calculated field in the form. Someone enters a number (say x ordered items) and the calculated field shows the total amount.
My idea is to use a Typoscript object field for this and make the calculation in TS. It is a simple calculation and in TSRef I saw something about a +calc datatype. Can someone explain to me how to code this in TScript? There is very little information on this topic, so I hope someone can shed some light on this.
Thanks for any help,
Erwin
Hello Erwin,
I would integrate this in a similar way. Adding a dynamic typoscript marker and fill it with (e.g.) a userFunc output.
Example for using a dynamic typoscript marker in powermail:
#77031
Alex
Hi Alex,
thanks for the info. I had a look at the examples you refered to and I understand the meaning (I think). If I am correct the actual 'calculation' is done by a PHP-script, right? However, from the TSRef I get (section 1.3):
Calculating values (+calc):
Sometimes a datatype is set to "something +calc". "+calc" indicates that the value is calculated with "+-/*". Be aware that the operators has no "weight". The calculation is done in the order of the operators.
Example:
45 + 34 * 2 = 158(which is the same as this is ordinary arithmetic: (45+34)*2=158 )
Therefore I understood that it should be possible to perform the calculation in TScript.
I tried:
10.totalcost = TEXT
10.totalcost.value = 5*10
and the result is: '5*10' and not '50'. Therefore the multiplication did not work.....
I tried:
10.totalcost = +calc
10.totalcost.value = 5*10
but this leads to nothing....
I also tried:
lib.totalcost = COA_INT
lib.totalcost {
10 = TEXT
10.value = <label for="uid80">Totale kosten van deze bestelling</label>
20 = CONTENT
20.data = TSFE:fe_user|sesData|powermail_429|uid79
}
In the powermail form the label is displayed. The second 'statement' should be something like:
1) get the user input from field uid79 on powermail page 429;
2) multiply this entry with a number
3) display this number in the powermail field uid80.
I did not include the multiplication because:
a) I do not know how to do arithmatic in TScipt;
b) I can not display the result back in a powermail field;
Could you provide a hint on how to perform the calculation in TScript? And how can I display the result in a powermail field?
thanks for any help,
regards,
Erwin
Hello Erwin,
I don't think that this is a newbie question.
I have invested some time and wrote a HOWTO:
#84633
So I think you should spend a beer for this small HOWTO 😃
Alex
Hi Alex,
many thanks for the example. I admit fully: this is something way beyond my league! And definitely you earned a beer! I hope the HOWTO will be of help to others as well.
Regards,
Erwin