forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 plugins => Topic started by: cimona on April 16, 2011, 03:04:13 am

Title: Most viewed albums for cpg 1.5 I got stuck!
Post by: cimona on April 16, 2011, 03:04:13 am
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 (http://forum.coppermine-gallery.net/index.php/topic,52809.0.html)
my gallery is
http://xoxos4u.com (http://xoxos4u.com)
most viewed albums link
http://xoxos4u.com/thumbnails.php?album=topnalb (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
Code: [Select]
                case 'alblist':
                    list_albums();
                    break;

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

open
include/functions.inc.php

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

Code: [Select]
    $album_types = array(
        'albums' => array('lastalb')
    );

replace with
Code: [Select]
    $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:
Code: [Select]
    $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
Code: [Select]
    $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!
Title: Re: Most viewed albums for cpg 1.5 I got stuck!
Post by: Αndré on April 18, 2011, 01:38:48 pm
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 (http://forum.coppermine-gallery.net/index.php/topic,63706.0.html) 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 :)
Title: Re: Most viewed albums for cpg 1.5 I got stuck!
Post by: cimona on April 22, 2011, 08:04:47 pm
Hi, thank you for your reply, I will have a look and write back if I can do this myself.