Most viewed albums for cpg 1.5 I got stuck! Most viewed albums for cpg 1.5 I got stuck!
 

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

Most viewed albums for cpg 1.5 I got stuck!

Started by cimona, April 16, 2011, 03:04:13 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

cimona

Hi, I used this mod on cpg 1.4 and I tried to add it back now after I upgrated to 1.5 but I could not do it all right.
http://forum.coppermine-gallery.net/index.php/topic,52809.0.html
my gallery is
http://xoxos4u.com
most viewed albums link
http://xoxos4u.com/thumbnails.php?album=topnalb
Please note that I have 0 knowledge of php and I just guessed my way until here.
The albums do show up but when I click on one of the image doesn't take me to the intermediate image its going to the same page and thats because there is a part of code in theme.php that I have no idea how to change.

I will write first everything I changed and the last the part I got stucked with.


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
                case 'alblist':
                    list_albums();
                    break;


add after
               case 'topnalb':
                        display_thumbnails('topnalb', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        break;


open
include/functions.inc.php

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

        return $rowset;
        break;


after add
   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
$lang_meta_album_names['favpics'] = 'Favorite files';

add after
$lang_meta_album_names['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)

    $album_types = array(
        'albums' => array('lastalb')
    );


replace with
    $album_types = array(
       'albums' => array('lastalb' || $aid == 'topnalb')
    );



And now the part I believe I have to edit but not sure how
in  1.5 cpg is like this:
    $i = 0;
    global $thumb;  // make $thumb accessible to plugins
    foreach($thumb_list as $thumb) {
        $i++;
        if ($mode == 'thumb') {
            if (in_array($aid, $album_types['albums'])) {
                $params = array(
                    '{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}'   => "thumbnails.php?album={$thumb['aid']}",
                    '{THUMB}'      => $thumb['image'],
                    '{CAPTION}'    => $thumb['caption'],
                    '{ADMIN_MENU}' => $thumb['admin_menu'],
                );


and in cpg 1.4
    $i = 0;
    foreach($thumb_list as $thumb) {
        $i++;
        if ($mode == 'thumb') {
            if ($aid == 'lastalb' || $aid == 'topnalb') {
                $params = array('{CELL_WIDTH}' => $cell_width,
                    '{LINK_TGT}' => "thumbnails.php?album={$thumb['aid']}",
                    '{THUMB}' => $thumb['image'],
                    '{CAPTION}' => $thumb['caption'],
                    '{ADMIN_MENU}' => $thumb['admin_menu']
                    );


Thanks in advance!

ΑndrĂ©

I haven't read your code changes, but you don't need to edit core files to add more meta albums to your gallery in cpg1.5.x. There's already a plugin called More meta albums that add new meta albums to your gallery. It currently lacks of the desired 'most viewed albums' meta album, but it could be added quite easy.

cpg1.5.x stores how often an album has been viewed. The mod for cpg1.4.x uses the sum of all file views of each album to create the meta album.

If I have some spare time I'll add those meta albums to the plugin. If you're faster than me, feel free to share the updated plugin with us :)

cimona

Hi, thank you for your reply, I will have a look and write back if I can do this myself.