Hi
I just wanted to show total files like this 100,522 instead of 100522
And the same for total files in each category on the index page.
Any help would be good couldn't work out how to do it myself
Thanks 8)
there's a thread in the german support board...
http://forum.coppermine-gallery.net/index.php?topic=47755.0
This is not a copy/paste ready to go solution. The function is able to add the 'divider' if you pass the data to it. GauGau's first post tells where to add code to call the function (index.php).
You can use the function I provided in the thread Stramm refered to for your issue as well. The default separator is a dot, but you can override it as second parameter. Here's the function from that other thread:function float2decSeparated($string, $separator = '.') {
$remainder = floor($string);
$counter=0;
$return = '';
//loop through the string and chop into triplets
while ($remainder >= 1) {
$number = $remainder - (floor($remainder/pow(10,3)) * pow(10,3));
$return = $number . $separator . $return;
//$number = sprintf ("%'{$fill}{$fit}s", $number); // fill the chop with leading zeros if needed
$remainder = floor($remainder/pow(10,3));
$counter++;
}
// chop the trailing separator
$return = rtrim($return, $separator);
return $return;
}
For your purposes, call the function with the second parameter that specifies "," as separator like this:float2decSeparated($string, ',')
The function is not fool-proof (yet), as it doesn't take into account floats (instead, they just get cut off, converting the number to integer), but it's a start, nor is it fail-proof against large numbers nor alphanumeric strings.
the php function number_format() should do too
Oh, I wasn't aware of that function. Link to docs: http://www.php.net/manual/en/function.number-format.php
@Stramm: please take a look at http://forum.coppermine-gallery.net/index.php?topic=47854.0
Does it matter where I put the code in index.php
The function definition should reside at the start of the PHP section. Exact location doesn't matter though.
Thanks for this and I changed the separator but it doesn't work ???
http://forum.coppermine-gallery.net/index.php?topic=47755.msg229109#msg229109
in index.php find
$statistics = strtr($lang_list_categories['stat1'], array('[pictures]' => $picture_count,
'[albums]' => $album_count,
'[cat]' => $cat_count,
'[comments]' => $comment_count,
'[views]' => $hit_count));
and replace with
$statistics = strtr($lang_list_categories['stat1'], array('[pictures]' => number_format($picture_count, 0, ',', '.'),
'[albums]' => number_format($album_count, 0, ',', '.'),
'[cat]' => number_format($cat_count, 0, ',', '.'),
'[comments]' => number_format($comment_count, 0, ',', '.'),
'[views]' => number_format($hit_count, 0, ',', '.')));
Thank you stramm, spot on don't know why GauGau gave me that code didn't need it to work, is there anyway of making the total files in each category look the same ;)
Quote from: will on November 07, 2007, 04:51:35 PM
don't know why GauGau gave me that code didn't need it to work
I already said that I wasn't aware of that PHP function. Read up what I wrote.
What you you expect: apologies for this? Your reply is just lame imo.