-
Notifications
You must be signed in to change notification settings - Fork 8
Math
Daniel Poulin edited this page Jul 2, 2012
·
1 revision
This applies the modulo operator to a numerator and denominator. Useful for outputting stuff every third, fourth, etc entry in a loop.
-
numerator
: The number on top of the fraction. -
denominator
: The number on bottom of the fraction.
If we are attempting to output something every third iteration of a channel entries, we could do the following:
{exp:channel:entries channel="blog"}
{if '{exp:surgeree:modulo numerator="{count}" denominator="3"}' == 0}
{count}
{/if}
{/exp:channel:entries}
That will output the following, for a channel consisting of 16 entries:
3
6
9
12
15
Applies division to passed parameters, then rounds up or down. Defaults to up.
-
numerator
: The number on top of the fraction. -
denominator
: The number on bottom of the fraction. -
round
: Whether to round the valueup
ordown
.- Default:
up
- Default:
{exp:surgeree:round_divide numerator="4" denominator="3"}
Will output:
2
Formats numbers according to passed parameters. Useful for localization.
-
number
: The number to format. -
precision
: How many digits past the decimal separator to output.- Note: Setting this value much higher than the precision of the
number
value is likely to give you values that are slightly off (e.g. 3.01 -> 3.010000000057). This is due to issues with php's conversion of strings to numbers. - Default:
2
- Note: Setting this value much higher than the precision of the
-
decimal
: What character to use for the decimal separator.- Default:
.
- Default:
-
separator
: What character to use for the "thousands separator".- Default:
,
- Default:
-
groupsize
: How many decimal places to group a number by with the "thousands separator".- Default:
3
- Default:
{exp:surgeree:format_number number="12343.90" precision="1" decimal="," separator="'" groupsize="4"}
Will output:
1'2343,9