coppermine-gallery.com/forum

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: bgrella on May 31, 2012, 11:37:30 PM

Title: Album hit counts
Post by: bgrella 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
Title: Re: Album hit counts
Post by: bgrella 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?
Title: Re: Album hit counts
Post by: Αndré 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.
Title: Re: Album hit counts
Post by: bgrella 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?
Title: Re: Album hit counts
Post by: Αndré 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
$superCage = Inspekt::makeSuperCage();
and below, add
    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();
        }
    }
Title: Re: Album hit counts
Post by: bgrella on June 04, 2012, 05:53:02 PM
Awesome!  Thank you.