Or is there any alternative to format numbers? Thanks! <3
Extension talk:NumberFormat
What's wrong on 1.32?
It complains there is no extension.json or something... I'm sorry I should have been more precise.
This is expected. Did you follow the installation instructions?
Oh Silly me, I was convinced that the old way of importing extensions was deprecated... Thanks, adding the require_once worked. Sorry and thanks for your time!
Reported with task T219061. Probably an issue with PHP 7.2.x!?
Our wiki needs to get for example 1234.50
from 1234.501
(IOW: no thousands separator and 2 decimal places) but the round function of PHP doesn't keep dangling zeros and therefore the same is true for the round
available in #expr
. Would we get the requested result by {{#number_format:1234.501|2|.|}}
?
Maybe this question seem redundant, but the combination of empty thousands_sep and dangeling zeros is crucial for us and the French example combines a lot of features which (sort of) confuses me. Thanks for your help :)
--Uncopy (talk) 21:17, 26 October 2018 (UTC)
- BTW: the example link is broken. Hopefully, the next will be somewhere on https://xen.wiki --Uncopy (talk) 21:37, 26 October 2018 (UTC)
Hi,
{{#number_format:1234.501|2|.|}}
returns 1234.50
- Setup
- MediaWiki 1.29.0-rc.1 (929f8dc) 01:59, 8 July 2017
- PHP 5.6.30-0+deb8u1 (apache2handler)
- MariaDB 10.0.31-MariaDB-1~jessie
- NumberFormat 0.8.1 (e879011) 14:15, 15 August 2015
- Issue
PHP Warning: number_format() expects parameter 2 to be long, string given in /../w/extensions/NumberFormat/NumberFormat.php on line 81
@Pastakhov: I cannot tell exactly if this started out after the upgrade to 1.29 or if this was already present before. I found this in the servers error log.
Thanks for report, see https://gerrit.wikimedia.org/r/364167
Hi, it seems that this extension doesn't work with negative numbers. Is that correct? I thought it would be a good alternative for formatnum, because formatnum gives errors with php 5 and this one doesn't. But I didn't think it would ignore negative numbers. Is this a bug?
Hi! Yes, it is a bug. I'll fix it, thanks for report.
The bug has been fixed in version 0.8.0
That's absolutely great. Thank you for your effort and work. This is much appreciated!
Indeed it is! Thanks Pavel! Sorry that my php-knowledge is non-existent...
@User:Pastakhov It will be nice if you could tag this commit with 0.8.1
Thanks and cheers
Done
Hello Patrick & Pavel,
I just wanted to say "Thanks a lot" for this great extension!
On my site I show prices with help of SMW. The problem was that prices like 27,10 € were shown as 27,1 € and not as 27,10 €. First I played around with {{padright:{{#ifeq:{{#len:foo}}|2|foo,|foo}}|5|0}}
(which worked), but then I found your extension which is much more convenient.
Just a hint for German users: If you have a number like 27,1 and want to convert it to 27,10 use the following code:
{{#number_format:your_number|2|,|.|,}}
Thanks again!
Thanks for the feedback! I am glad that this extension helps you :-)
I love the idea of your extension. I am currently working on a pet project to build a complete, semantic CMDB so I need to be able to get rid of the comma in Office 2010 (just for example).
Do you know how I could use this function for inline quieries and the like? Most everything I'm doing is storing each piece of information and it's properties (software title, product key, vendor, version, etc) as one 'page' and calling queries throughout the rest of the site to aggregate all of that data together, using the semantic properties to pull exactly what we need every time.
Any help would be greatly appreciated!
Hi, I'm not quite sure what the problem is.
I use this extension to clean the user input: [[MyNumberProperty::{{#number_format:{{{Value|0}}}|_|.||,}}]]
And clear the result of the query:
{{#ask: ... |?MyNumberProperty | mainlabel=- | format=array | name=myArray }} {{#arrayprint:myArray |<br /> |@@@@|{{#number_format:{{#explode:@@@@|<PROP>|0}}|_|.||,}} }}
There may be bugs, so it is not a real-life example.
For simplicity, I use a template Num
: {{#iferror: {{#if: {{{1|}}} | {{#number_format:{{{1|0}}}|_|.||,}} | 0 }} | 0 }}
Then, {{#arrayprint:myArray |<br /> |@@@@|{{Num|{{#explode:@@@@|<PROP>|0}}}} }}
The problem is quite obviously me. :)
In all seriousness, I'm just getting my feet wet with MediaWiki. I tried out DokuWiki but it was so limited, so I'm coming into MediaWiki with bad forms already in my head, and I've only been at it a week or two. That's why I asked how one would accomplish it, not if it could.
And thank you for the awesome example. You have given me more fodder for learning in this one message than I have seen all week. I'm loving all that SMW will do, and I'm trying to learn it as fast as I can. But it seems like I'm coming in late in the game!
I'll try your example out tomorrow and see if I can figure out the syntax.
Thanks again!
There are no older topics