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

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

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 1 Guest 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;
                }
            }