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: Display file and album views added up together  (Read 6351 times)

0 Members and 1 Guest are viewing this topic.

twmyb

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Display file and album views added up together
« 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]
« Last Edit: February 05, 2014, 12:25:26 pm by Αndré »
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Display file and album views added up together
« Reply #1 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?
Logged

twmyb

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Display file and album views added up together
« Reply #2 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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Display file and album views added up together
« Reply #3 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?
Logged

twmyb

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Display file and album views added up together
« Reply #4 on: February 04, 2014, 06:22:07 pm »

Yes :)
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Display file and album views added up together
« Reply #5 on: February 05, 2014, 12:23:35 pm »

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":
So additionally to the other topic you want to move the album information below the album thumbnail, right?

I'll create the mod soon.
Logged

twmyb

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Display file and album views added up together
« Reply #6 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
Logged

Fifth Harmony

  • Coppermine newbie
  • Offline Offline
  • Posts: 18
Re: Display file and album views added up together
« Reply #7 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.
Logged

Fifth Harmony

  • Coppermine newbie
  • Offline Offline
  • Posts: 18
Re: Display file and album views added up together
« Reply #8 on: February 10, 2014, 10:48:18 pm »

Did I miss how to do this?  :)
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Display file and album views added up together
« Reply #9 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;
                }
            }
« Last Edit: February 11, 2014, 11:37:36 am by Αndré »
Logged
Pages: [1]   Go Up
 

Page created in 0.069 seconds with 20 queries.