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: [Mod] "Most viewed albums" meta album  (Read 12992 times)

0 Members and 1 Guest are viewing this topic.

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
[Mod] "Most viewed albums" meta album
« on: May 23, 2008, 10:09:14 am »

This mod adds a new meta album to show most viewed albums.

Demo: http://vanrokken.altervista.org/thumbnails.php?album=topnalb

Usage: to include this meta album in Main page/Album list display, add 'topnalb' code to your Configuration > Album list view > Main page content list (E.g. anycontent/breadcrumb/catlist/alblist/lastalb,1/topnalb,1).
To add a link "Most viewed albums" to your Gallery sub menu, enter "Most viewed albums" in "Name of your custom link" field, "thumbnails.php?album=topnalb" in "URL of your custom link" field under Configuration > Themes settings

Files to edit:
index.php
include/functions.inc.php
lang/english.php
(repeat for all the desired language files)
themes/your_theme/theme.php


OPEN
index.php

FIND
Code: [Select]
                    case 'lastalb':
                        display_thumbnails('lastalb', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        break;

AFTER, ADD
Code: [Select]
                       
                    case 'topnalb':
                        display_thumbnails('topnalb', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        break;                       


OPEN
include/functions.inc.php

FIND
Code: [Select]
                $rowset = CPGPluginAPI::filter('thumb_caption_favpics',$rowset);

                return $rowset;
                break;

AFTER, ADD
Code: [Select]
               
        case 'topnalb': // Last albums to which uploads
                if ($META_ALBUM_SET && $CURRENT_CAT_NAME) {
                        $album_name = $lang_meta_album_names['topnalb'].' - '. $CURRENT_CAT_NAME;
                } else {
                        $album_name = $lang_meta_album_names['topnalb'];
                }

                $META_ALBUM_SET_MWA = str_replace( "aid", $CONFIG['TABLE_PICTURES'].".aid" , $META_ALBUM_SET );

                $query = "SELECT count({$CONFIG['TABLE_ALBUMS']}.aid) FROM {$CONFIG['TABLE_PICTURES']},{$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND approved = 'YES' $META_ALBUM_SET_MWA GROUP BY {$CONFIG['TABLE_PICTURES']}.aid";

                $result = cpg_db_query($query);
                $count = mysql_num_rows($result);
                mysql_free_result($result);

                $query = "SELECT *, SUM({$CONFIG['TABLE_PICTURES']}.hits) AS hits, {$CONFIG['TABLE_ALBUMS']}.title AS title, {$CONFIG['TABLE_ALBUMS']}.aid AS aid FROM {$CONFIG['TABLE_ALBUMS']},{$CONFIG['TABLE_PICTURES']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND {$CONFIG['TABLE_PICTURES']}.approved = 'YES' AND hits > 0 $META_ALBUM_SET_MWA GROUP BY {$CONFIG['TABLE_ALBUMS']}.aid ORDER BY hits DESC $limit";
               
                $result = cpg_db_query($query);
                $rowset = cpg_db_fetch_rowset($result);
                mysql_free_result($result);

                if ($set_caption) build_caption($rowset,array('hits'));               

                $rowset = CPGPluginAPI::filter('thumb_caption_topnalb',$rowset);

                return $rowset;
                break;


OPEN
lang/english.php

FIND
Code: [Select]
  'favpics'=> 'Favorite Files',  //cpg1.4
AFTER, ADD
Code: [Select]
  'topnalb' => 'Most viewed Albums', 

OPEN
themes/your_theme/theme.php

FIND
function theme_display_thumbnails
(if absent, copy and paste it from themes/sample/theme.php)

FIND
Code: [Select]
        $theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $aid == 'lastalb' ? $lang_album_list['album_on_page'] : $lang_thumb_view['pic_on_page']));
REPLACE WITH
Code: [Select]
        $theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => ($aid == 'lastalb' || $aid == 'topnalb') ? $lang_album_list['album_on_page'] : $lang_thumb_view['pic_on_page']));
FIND
Code: [Select]
            if ($aid == 'lastalb') {
REPLACE WITH
Code: [Select]
            if ($aid == 'lastalb' || $aid == 'topnalb') {
SAVE AND CLOSE ALL FILES
« Last Edit: December 22, 2008, 11:39:54 am by Ludo »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: [Mod] "Most viewed albums" meta album
« Reply #1 on: May 23, 2008, 01:01:51 pm »

Thanks for your contribution; looks very promising. I'd like to hear some test results. If the feedback is positive, I'd like to consider this mod to go into the core for cpg1.5.x, so everybody please test thoroughly and post feedback.
Logged

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: [Mod] "Most viewed albums" meta album
« Reply #2 on: May 23, 2008, 02:19:02 pm »

Thank you very much for your appreciation, GauGau  :-[ ;)
Mod was witten from scratch yesterday night, so it lacks testing nearly at all.  :-\ :)
Logged

Hein Traag

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: nl
  • Offline Offline
  • Gender: Male
  • Posts: 2166
  • A, B, Cpg
    • Personal website - Spintires.nl
Re: [Mod] "Most viewed albums" meta album
« Reply #3 on: May 23, 2008, 02:27:10 pm »

"There was an error while processing a database query "

Database gone for lunch ?
Logged

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: [Mod] "Most viewed albums" meta album
« Reply #4 on: May 23, 2008, 02:35:53 pm »

Huh, new meta album seems to work only for registered users...definitely lacks testing!  :-[  ;D
I'm going to try to fix it ASAP, sorry


Edit: bug fixed and mod code above edited accordingly
« Last Edit: May 23, 2008, 02:57:52 pm by Ludo »
Logged

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: [Mod] "Most viewed albums" meta album
« Reply #5 on: May 26, 2008, 09:29:19 am »

SQL queries rewritten to comply with CPG layer
Logged

armus

  • Coppermine newbie
  • Offline Offline
  • Posts: 14
    • glamour galleries
Re: [Mod] "Most viewed albums" meta album
« Reply #6 on: November 01, 2009, 02:27:59 pm »

Hi Ludo, i am using your this Mod and "album views in albums stats on Album list" http://forum.coppermine-gallery.net/index.php?topic=29118.0

And also directly linking to the full size images(files of jpeg,etc) from the album thumbnails "no indermediate pages nor full size image pages"

Ofcourse Album View count is not working by these ways however it is possible to add counter to the aid (album id) instead pid (picture id), if i can clear, we should be able to add counter raise according to album views (whenever an album page opened) not the full-size image view page opened.

Have you did it? Or do you know how to do it?
Logged

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: [Mod] "Most viewed albums" meta album
« Reply #7 on: November 02, 2009, 09:59:05 am »

To accomplish that, you should add a counter field for album views to albums table in db, and a function to increase that counter at every visit in thumbnail page.
Logged

armus

  • Coppermine newbie
  • Offline Offline
  • Posts: 14
    • glamour galleries
Re: [Mod] "Most viewed albums" meta album
« Reply #8 on: November 02, 2009, 02:52:35 pm »

I think i can not do that, wheneve i add or edit a field in MySQL , entire Coppermine gives failure.
Logged
Pages: [1]   Go Up
 

Page created in 0.024 seconds with 20 queries.