0

I am trying to get a snippet that calculates a value and compare the result to a number - the value is correctly outputted from my snippet when I include the var by itself. However when I use the snippet in a comparison if statement it doesn't work. Here is my code:

{if total-positive-votes > 5} true {/if}

My snippet:

{exp:math_plus calculate="{var2}-({var1} - {var2})" var1="{overall_count}" var2="{overall_sum}"}
   {math_plus_result}
{/exp:math_plus}

Which outputs the following numbers correctly (each comma is a would be comparison):

0, 1, 1, 4, 0, 0, 41, 8 

So my comparison statement should output true on 41 and 8 but nothing comes back. Any one know why this isn't working? The funny thing is it used to work but I didn't use or upgrade this site for 2 years and it broke without me changing anything. Go figure!

1 Answer 1

0

If I understood you right, total-positive-votes is your snippet.

I think you're over complicating things, since there's a pack of mathematical operators that can be used on conditionals.

{if overall_sum - (overall_count - overall_sum) > 5}
  true
{/if}

Or, to keep it even simpler, because multiplications always happen before sum, anyway:

{if 2 * overall_sum - overall_count > 5}
  true
{/if}
1
  • I am on version 2.5 - I guess I should upgrade to 2.10 because the new built in operators are bound to help! Commented May 31, 2015 at 2:47

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.