Lack of interest "abs" filter for templates

This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.

DragonByte Tech

Well-known member
(This could potentially also work as an optional parameter to the existing "number" filter.)

Currently, if you want the absolute number in a template, you have to do silliness like this:
HTML:
<xf:set var="$amount" value="{{ $transaction.amount < 0 ? ($transaction.amount * -1) : $transaction.amount }}" />
Therefore I would like to request being able to pipe the variable to an "abs" filter that just runs PHP's abs().

Use case: Let's say that I am looping through transactions, and I want to display a "pretty" phrase, e.g. "Earned X points" or "Spent Y points". Currently, it would say "Spent -1 points" because the transaction amount is a signed value in the database, unless I do that <xf:set /> as above.


Fillip
 
Upvote 1
This suggestion has been closed. Votes are no longer accepted.
Top Bottom