Dear Laisvunas;
I am trying to do something very similar to what Mark wants (on post #2 and your response and his on #3 and #4). But I am not getting any love.
It should not required any php but still I have even change in the templates preferences to allow php and php parsing stage, but none have worked.
After installing your plugin
I am trying to do the following:
Makes sense? can you help or point where to go, what to do? please, thanks.
my code is:
{exp:weblog:entries weblog="orders" orderby="entry_id" sort="desc" parse="inward"}
{exp:simple_math calculate="{quantity} + {unit_price}"}
{/exp:weblog:entries}
Thanks, but now, I get:
Parse error: syntax error, unexpected ‘<’ in /home/.aaaaa/aaaaaaa/aaaaaa.com/system/plugins/pi.simple_math.php(65) : eval()’d code on line 1
I read some suggestions here on the post, about this error, but I am still not sure.
Do I need to keep the parse=”inward” or remove it? from the above code?
Do I need to leave on the template preferences: Allow PHP? yes or no and PHP Parsing Stage - in or out?
Also, on your previous replies to others, what do you mean by:
You get this error because {exp:simple_math} is evaluated before the variable which is the value of the “calculate” parameter.
AND
Fix the parse order and there will be no error message. You should add that parameter to the tag {my_unparsed_variable} belongs to
….How/where do I do this little lost, sorry…
thanks again for your prompt reply. crossing my fingers here…
Hi,
Check what the variables {quantity} and {unit_price} output outside {exp:simple_math} tag:
{exp:weblog:entries weblog="orders" orderby="entry_id" sort="desc" parse="inward"}
{quantity}, {unit_price}
{/exp:weblog:entries}
If you get error message
syntax error, unexpected ‘<’ in /home/.aaaaa/aaaaaaa/aaaaaa.com/system/plugins/pi.simple_math.php(65) : eval()‘d code on line 1
it means that some variable you use inside “calculate” parameter outputs “<” symbol.
Ok, two more silly questions:
1) can I change something, and where, in order to make numbers have a fixed decimal case for 2, and thousands separator. IE: 1,000,00 rather than 1000 ?? how/where to make this changes?
2) is there a way to calculate a date? for instance: I have a field (days) that has 10 (or 20 or ..) and I have a field for date such as 12/12/2009. I wanted to have the {date}+(days) output the result in a date format: 12/22/2009. is there a easy way to do such (I havent tried yet, figured I would ask first..)
Thanks again Laisvunas, A+++ plugin!!
Hi,
1) I do not know how to prettify the numbers. It would be best if someone would write a plugin doing this.
2) in some cases you can use Simple Math plugin together with WI Friendlee Date plugin, but as far as I know there is no general solution. Again, it would be best if someone would write a plugin doing this.
Back:
I have found a way to get my numbers working:
http://expressionengine.com/downloads/details/number_format/
So, the numbers work fine, if I just use their info.. for example:
{exp:number_format number="{order_price}" decimals="2" dec_point="," thousands_sep="."}
will output me something like 1.000,00
However, I have tried to use that in conjunction with yours, and it’s not working. I was wondering where was I wrong. I tried two ways, neither did any good:
(your example that works:
{exp:simple_math calculate="{order_quantity}*{order_price}"}
comes with a result 2000)
now:
{exp:number_format number="{exp:simple_math calculate="{order_quantity}*{order_price}"}" decimals="2" dec_point="," thousands_sep="."}
or
{exp:simple_math calculate="{exp:number_format number="{order_quantity}*{order_price}" decimals="2" dec_point="," thousands_sep="."}"}
none of them output the expected 2.000,00
Any ideas why? way around it? better coding on my end? thanks thanks thanks
Hey, just got your email. You can’t have one EE tag’s result supply the parameter for another EE tag.
However, you can turn on PHP in the template for “output” (I think) and then do this:
<?php
echo number_format( floatval("{order_quantity}") * floatval("{order_price}"), 2);
?>
Sorry, I didn’t test this out. Please let me know if it works.
Yo’all Rock!
Robert, It did work !!!! Thanks
So now the last thing I need to figure it out somehow is to get a specific date , like today, and add 10, or 20… (for net 10, net 20) and have it tell me what the date will be based on the 10 or 20, or…
Also, a little out of the simple math realm, but in the topic,.. ever since I combined both scrips using Robert’s suggestion above, now, if I have a field that is blank, its showing “0” is there a way to leave blank if its bkank rather than output “0”
And if I have a whole number, like 5.000,00 is there a way to show only 5.000 (without the decimals if there are no decimals in that specific number?)
Thanks again for any pointers relevant to the three questions above..
Thanks
Hey I’m having problems with this plugin.
When I preview the page the following message appears in the front end -
Parse error: syntax error, unexpected T_DNUMBER in /www/eh10375/public_html/ee_glassworks/vpsys/plugins/pi.simple_math.php(65) : eval()'d code on line 1
This is the template code.
<div class="{switch="resultsBk|resultsBk2|resultsBk3|resultsBk4"}">
<a href="http://{permalink=">{image1_sml}</a>
<h3><a href="http://{permalink=">{designer_search_field}</a></h3>
{products_title}
{if foxee_is_on_sale}<span class="priceCross">{foxee_price}</span> - {exp:simple_math calculate="({foxee_price}/100)*{foxee_price}"}
<span class="sale2">On Sale - {foxee_saleprice}</span>{if:else}{foxee_price}{/if}
<h4>{tag}</h4>
</div>
Any help would be splendid.
Thanks
S
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.