Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Divider In Total Files In Gallery  (Read 5780 times)

0 Members and 1 Guest are viewing this topic.

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Divider In Total Files In Gallery
« on: October 27, 2007, 12:37:56 am »

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

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Divider In Total Files In Gallery
« Reply #1 on: October 27, 2007, 08:43:24 am »

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

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Divider In Total Files In Gallery
« Reply #2 on: October 27, 2007, 10:47:37 am »

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:
Code: [Select]
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:
Code: [Select]
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.

Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Divider In Total Files In Gallery
« Reply #3 on: October 27, 2007, 10:58:34 am »

the php function number_format() should do too

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Divider In Total Files In Gallery
« Reply #4 on: October 27, 2007, 11:06:56 am »

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
Logged

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: Divider In Total Files In Gallery
« Reply #5 on: October 27, 2007, 01:11:58 pm »

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

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Divider In Total Files In Gallery
« Reply #6 on: October 28, 2007, 10:36:26 am »

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

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: Divider In Total Files In Gallery
« Reply #7 on: November 06, 2007, 04:51:22 pm »

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

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Divider In Total Files In Gallery
« Reply #8 on: November 06, 2007, 05:32:06 pm »

http://forum.coppermine-gallery.net/index.php?topic=47755.msg229109#msg229109

in index.php find
Code: [Select]
            $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
Code: [Select]
            $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

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: Divider In Total Files In Gallery
« Reply #9 on: November 07, 2007, 04:51:35 pm »

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

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Divider In Total Files In Gallery
« Reply #10 on: November 08, 2007, 07:26:00 am »

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.
Logged
Pages: [1]   Go Up
 

Page created in 0.021 seconds with 21 queries.