Advanced search  

News:

cpg1.5.46 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter recently discovered vulnerabilities. It is important that all users who run version cpg1.5.44 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Most viewed albums for cpg 1.5 I got stuck!  (Read 2463 times)

0 Members and 1 Guest are viewing this topic.

cimona

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
    • Simona Mar
Most viewed albums for cpg 1.5 I got stuck!
« 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
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
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!
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15455
Re: Most viewed albums for cpg 1.5 I got stuck!
« Reply #1 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 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 :)
Logged

cimona

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
    • Simona Mar
Re: Most viewed albums for cpg 1.5 I got stuck!
« Reply #2 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.
Logged
Pages: [1]   Go Up
 

Page created in 0.023 seconds with 21 queries.