Math Plus

Developer

Laisvunas

3rd Party (Free)


EE Version Support

  • ExpressionEngine 1.x
  • ExpressionEngine 2

Compatibility

If an item is crossed out, it might be untested, not applicable or incompatible. Contact the developer to be sure.

  • Updater
  • Multi Site Manager
  • Stand Alone Entry Form
  • Low Variables
  • Content Elements
  • Better Workflow
  • Matrix
  • Grid
  • Webservice
  • Publisher

Requirements

  • jQuery for the Control Panel

Add-On Type(s)

Plugin

Tags

This plugin provides support for doing simple mathematical operations in templates. There is already the plugin Simple Math which has the same purpose. Math Plus plugin differs from Simple Math only in one feature: it is required to use a tag pair instead of single tag. Tag pair allows for better control of the parse order.

PARAMETERS

1) calculate - Required. Alows you to input a string consisting of numbers,
symbols of mathematical operations and round brackets, e.g
calculate = “(10 + 5) / 3”. Examples of symbols of supported mathematical operations are:
+ (addition), - (subtraction), * (multiplication), / (division),
% (division remainder), ++ (increment),—(decrement).

2) invalid_input - Optional. Accepts two values: “alert” and “silence”.
Default value is “silence”. If the value is “alert”, then in cases when
the plugin has some problem with parameters,  PHP alert is being shown;
if the value is “silence”, then in cases when the plugin has
some problem with parameters, it finishes its work without any alert being shown.
Set this parameter to “alert” for development, and to “silence” - for deployment.

3) var1, var2, var3, var4 ... var48, var49, var50 - Optional. Allows you to input numbers.
Used to gain more security - the values of these parameters will be checked if they really are numbers.
Each these parameters can be used inside “calculate” parameter. E.g. var1=“10” var2=“5” var3=“3” calculate=”({var1} + {var2}) / {var3}”

4) on_non_numeric_vars - Optional. Allows you to specify what variable {math_plus_result} should output in case
some of var1, var2, var3, etc. variables were found to be non numeric.

5) decimal_places - Optional. Specifies how many decimal places the computed number will have.
Default value is 2.

6) decimal_sep - Optional. Specifies what string to use for decimal point in computed number. Default
value is “.”

7) thousand_sep - Optional. Specifies what string to use for thousands separator in computed number.
By default thousands will not be separated.

USAGE

Use this plugin as folllows:

{exp:math_plus calculate="(10 + 5) / 3"}
{math_plus_result}
{/exp:math_plus}

Or use it this way:

{exp:math_plus calculate="({var1} + {var2}) / {var3}" var1="10" var2="5" var3="3"}
{math_plus_result}
{/exp:math_plus}

Format resulting number according your needs:

{exp:math_plus var1="1293.50" var2="1.013" calculate="{var1} * {var2}" decimal_places="2" decimal_sep="." thousand_sep=","}
&#123

;math_plus_result}
{/exp:math_plus}

This entry was created March 25, 2010, 7:28 am.
This entry was last updated September 28, 2014, 8:58 am.

Disclaimer: Information about ExpressionEngine add-ons is provided as a service to you, the user, and every member of the ExpressionEngine community. devot:ee is not responsible if you hose, mangle, wreck, or otherwise destroy your EE website by installing an add-on that you found out about at this site, regardless of its rating, Favorites status, commercial or free status, or general popularity. Caveat EEmptor!

Returns: devot:ee has a 30-day return policy on all commercial add-ons sold through devot-ee.com. If you need to return an add-on, do not go to the developer or the developer's site, but rather visit our returns page at https://devot-ee.com/returns to initiate your return. If you have questions, email support@devot-ee.com.

1 Review:

Peter Ripley 01.06.12

Peter Ripley
Rating - {addon_rating_average}

This plugin works very nicely.  The developer had excellent response time to my questions and added a feature at my request very quickly (overnight). 

An undocumented feature is that you can pass php functions through the ‘calculate’ parameter making this a very powerful little plugin.