Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-09-28 20:40:45

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Download count: Adding a comma separator to thousands, millions, etc.

Is it possible to display files with more than 999 downloads with comma separators in their download counts—ie. as “1,001” instead of “1001”?

Offline

#2 2014-09-28 21:44:08

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: Download count: Adding a comma separator to thousands, millions, etc.

You could pass it through number_format() function, e.g.

<txp:etc_query data="{?downloads|0|number_format}" globals="thisfile" />

or rah_function, or raw <txp:php />.

Edit: or more robust

<txp:etc_query data='{?|<txp:file_download_downloads />|number_format}' />

Last edited by etc (2014-09-29 08:02:17)

Offline

#3 2014-09-28 21:47:39

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Download count: Adding a comma separator to thousands, millions, etc.

Using rah_function you could use number_format to format the value. Something along the lines of:

<txp:rah_function call="number_format" number='<txp:file_download_downloads />' decimals="0" decimal_point="." thousands_separator="," />

Offline

#4 2014-09-29 15:06:53

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: Download count: Adding a comma separator to thousands, millions, etc.

Thank you, friends! I’ll work on this again Wednesday and I’ll report back if anything goes amiss. But I anticipate this will solve the problem with grace. Cheers!

Offline

Board footer

Powered by FluxBB