The attached add-on files may be out of date. Please visit Devot-ee for the latest versions.
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.
USAGE
Use this plugin as folllows:
{exp:math_plus calculate="(10 + 5) / 3"}
{math_plus_result}
{/exp:math_plus}Thanks for creating Math Plus.
It was just what I needed for doing a calculation and passing the result to a another plugin (See this thread).
Cheers!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.