Divider In Total Files In Gallery Divider In Total Files In Gallery
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Divider In Total Files In Gallery

Started by will, October 27, 2007, 12:37:56 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

will

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)

Stramm

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).

Joachim Müller

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.


Stramm

the php function number_format() should do too

Joachim Müller


will

Does it matter where I put the code in index.php

Joachim Müller

The function definition should reside at the start of the PHP section. Exact location doesn't matter though.

will

Thanks for this and I changed the separator but it doesn't work ???

Stramm

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, ',', '.')));

will

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 ;)

Joachim Müller

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.