Display file and album views added up together Display file and album views added up together
 

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

Display file and album views added up together

Started by twmyb, February 03, 2014, 08:21:33 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

twmyb

Hi, I know there is another topic on this but I'm not sure if this is slightly different and didn't want to hijack.

I'd like to display the album views and file views (of the album) added up together under the thumbnails on the main page. For example:

http://oi62.tinypic.com/2qlc02g.jpg
http://oi58.tinypic.com/3091w6v.jpg

Can anyone help me with this? Thanks!


[Edit: attached hotlinked images]

Αndré

So additionally to the other topic you want to move the album information below the album thumbnail, right?

twmyb

Yes but I want them added up together. On the example I posted the album has 373 album views and 3032 file views. Under the album on the gallery main page it says 3405 views - so both album views and file views have been added together instead of displaying just one of them.

Αndré

Okay. Same question as in the other thread: do you want to take views of linked files (via the album keyword feature) into account?


Αndré

I just had a closer look at your screenshots and the screenshot in the other thread. It seems that your questions are identical and the answer to my question is actually "no":
Quote from: Αndré on February 04, 2014, 09:20:48 AM
So additionally to the other topic you want to move the album information below the album thumbnail, right?

I'll create the mod soon.

twmyb

Oh sorry about that. Here's the link to the gallery the screenshots are from if it helps at all: http://mileygallery.net/

Thanks for your help

Fifth Harmony

Yes this is exactly what I meant ;) I'll keep an eye out on this topic, thanks.

Fifth Harmony


Αndré

#9
To add the file views next to the album views, copy the functions theme_display_album_list and theme_display_album_list_cat from themes/sample/theme.php to your theme's theme.php file, if they don't exist.

Find
foreach($alb_list as $album) {
and below, add
            if ($alb_keyword = mysql_result(cpg_db_query("SELECT keyword FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = {$album['aid']} LIMIT 1"), 0)) {
                $keyword = "OR keywords LIKE '%$alb_keyword%'";
            } else {
                $keyword = '';
            }
            if ($file_hits = mysql_result(cpg_db_query("SELECT SUM(hits) FROM {$CONFIG['TABLE_PICTURES']} WHERE aid = {$album['aid']} AND approved = 'YES' $keyword"), 0)) {
                $album['alb_hits'] .= " / $file_hits file views";
            }

in both functions.


To sum up the album and file views for the "last updated albums" meta album (lastalb), open include/functions.inc.php, find
            if ($set_caption) {
                build_caption($rowset, array('ctime'), 'albums');
            }

and above, add
            foreach ($rowset as $key => $album) {
                if ($alb_keyword = mysql_result(cpg_db_query("SELECT keyword FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = {$album['aid']} LIMIT 1"), 0)) {
                    $keyword = "OR keywords LIKE '%$alb_keyword%'";
                } else {
                    $keyword = '';
                }
                if ($file_hits = mysql_result(cpg_db_query("SELECT SUM(hits) FROM {$CONFIG['TABLE_PICTURES']} WHERE aid = {$album['aid']} AND approved = 'YES' $keyword"), 0)) {
                    $rowset[$key]['alb_hits'] += $file_hits;
                }
            }