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: Album hit counts  (Read 3145 times)

0 Members and 1 Guest are viewing this topic.

bgrella

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Album hit counts
« on: May 31, 2012, 11:37:30 pm »

Hi

I'm using coppermine 1.5.20 (stable)

My site: http://www.garagewoodworks.com/Forum/forum_projects.php

The above gallery links users to http://www.garagewoodworks.com/copper/displayimage.php?album=27&pid=100#top_display_media for a project.

The hit counter isn't incrementing for a visit to the above link.  Is there any easy solution for this?  Can I add +1 to the table for the photo and +1 to the album table?

Please help.

Cheers,
Brian
Logged

bgrella

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Album hit counts
« Reply #1 on: May 31, 2012, 11:43:06 pm »

If I increment the table for the photo and album how is it best to treat multiple hits by the same user to the same album?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Album hit counts
« Reply #2 on: June 01, 2012, 05:11:30 pm »

A hit to an album is only added if the user views the thumbnail page, i.e. http://www.garagewoodworks.com/copper/thumbnails.php?album=27 - so you should link it to that page IMHO.
Logged

bgrella

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Album hit counts
« Reply #3 on: June 01, 2012, 05:25:48 pm »

Is it possible to increment the table 'albums' for that user after the user lands on the page '/displayimage.php?album=**'  by adding code to the displayimage.php page?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Album hit counts
« Reply #4 on: June 04, 2012, 04:49:42 pm »

Copy the function theme_display_image from themes/sample/theme.php to your theme's theme.php file if it doesn't exist. Then, find
Code: [Select]
$superCage = Inspekt::makeSuperCage();and below, add
Code: [Select]
    global $USER;
    $album = mysql_result(cpg_db_query("SELECT aid FROM {$CONFIG['TABLE_PICTURES']} WHERE pid = ".$superCage->get->getInt('pid')), 0);
    if (is_numeric($album)) {

        // Create an array to hold the album id for hits (if not created)
        if (!isset($USER['liv_a']) || !is_array($USER['liv_a'])) {
            $USER['liv_a'] = array();
        }

        // Add 1 to album hit counter
        if ((!USER_IS_ADMIN && $CONFIG['count_admin_hits'] == 0 || $CONFIG['count_admin_hits'] == 1) && !in_array($album, $USER['liv_a']) && $superCage->cookie->keyExists($CONFIG['cookie_name'] . '_data')) {

            add_album_hit($album);

            if (count($USER['liv_a']) > 4) {
                array_shift($USER['liv_a']);
            }

            array_push($USER['liv_a'], $album);
            user_save_profile();
        }
    }
Logged

bgrella

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Album hit counts
« Reply #5 on: June 04, 2012, 05:53:02 pm »

Awesome!  Thank you.
Logged
Pages: [1]   Go Up
 

Page created in 0.015 seconds with 20 queries.