forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 themes (visuals) => Topic started by: twmyb on February 03, 2014, 08:21:33 pm

Title: Display file and album views added up together
Post by: twmyb on February 03, 2014, 08:21:33 pm
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]
Title: Re: Display file and album views added up together
Post by: Α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?
Title: Re: Display file and album views added up together
Post by: twmyb on February 04, 2014, 04:14:14 pm
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.
Title: Re: Display file and album views added up together
Post by: Αndré on February 04, 2014, 04:17:31 pm
Okay. Same question as in the other thread: do you want to take views of linked files (via the album keyword feature) into account?
Title: Re: Display file and album views added up together
Post by: twmyb on February 04, 2014, 06:22:07 pm
Yes :)
Title: Re: Display file and album views added up together
Post by: Αndré on February 05, 2014, 12:23:35 pm
I just had a closer look at your screenshots and the screenshot in the other thread (http://forum.coppermine-gallery.net/index.php/topic,77170.msg372908.html#msg372908). It seems that your questions are identical and the answer to my question is actually "no":
So additionally to the other topic you want to move the album information below the album thumbnail, right?

I'll create the mod soon.
Title: Re: Display file and album views added up together
Post by: twmyb on February 05, 2014, 06:20:34 pm
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
Title: Re: Display file and album views added up together
Post by: Fifth Harmony on February 05, 2014, 09:41:31 pm
Yes this is exactly what I meant ;) I'll keep an eye out on this topic, thanks.
Title: Re: Display file and album views added up together
Post by: Fifth Harmony on February 10, 2014, 10:48:18 pm
Did I miss how to do this?  :)
Title: Re: Display file and album views added up together
Post by: Αndré on February 11, 2014, 11:29:52 am
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
Code: [Select]
foreach($alb_list as $album) {and below, add
Code: [Select]
            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
Code: [Select]
            if ($set_caption) {
                build_caption($rowset, array('ctime'), 'albums');
            }
and above, add
Code: [Select]
            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;
                }
            }