Advanced search  

News:

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

Pages: [1]   Go Down

Author Topic: don't show some albums on 'random pictures'  (Read 2290 times)

0 Members and 1 Guest are viewing this topic.

alexandre596

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
don't show some albums on 'random pictures'
« on: August 05, 2012, 09:37:04 pm »

is there any way to make all the pictures from one album don't showup on the 'random pictures', on the index? (it's not necessary to be only in the index, it can be to not showup on the 'random pictures' in all pages, but only in the first one, when you're not in any category, is enough)


thank you
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: don't show some albums on 'random pictures'
« Reply #1 on: August 06, 2012, 10:50:36 am »

Open include/functions.inc.php, find
Code: [Select]
case 'random': // Random filesand below, add something like
Code: [Select]
$RESTRICTEDWHERE .= ' AND r.aid != 123 ';
Logged

alexandre596

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: don't show some albums on 'random pictures'
« Reply #2 on: August 06, 2012, 05:42:31 pm »

thank you so much
I made it a little bit different, because several albums :P
(it's after the case 'random':)


Code: [Select]
    $albumoff[] = 699;
    $albumoff[] = 700;

    for($i = 0, $size = count($albumoff); $i < $size; $RESTRICTEDWHERE .= " AND r.aid != $albumoff[$i] ", ++$i);

thank you so much <3
Logged

alexandre596

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: don't show some albums on 'random pictures'
« Reply #3 on: August 06, 2012, 05:50:56 pm »

one thing I just noticed :P
doing  that way, the pictures won't show on the 'latestes uploades' pictures (os something like)
so I changed it a little bit:

here, the whole case 'random' :
(didn't change a lot, but it's better than naming every small change)

Code: [Select]
        $albumoff[] = 699;
        $albumoff[] = 700;

        $RANDOFF = $RESTRICTEDWHERE;
        for($i = 0, $size = count($albumoff); $i < $size; $RANDOFF .= " AND r.aid != $albumoff[$i] ", ++$i);

        if ($cat && $CURRENT_CAT_NAME) {
            $album_name = cpg_fetch_icon('random', 2) . $lang_meta_album_names['random'] . ' - ' . $CURRENT_CAT_NAME;
        } else {
            $album_name = cpg_fetch_icon('random', 2) . $lang_meta_album_names['random'];
        }

        $query = "SELECT COUNT(*)
                FROM {$CONFIG['TABLE_PICTURES']} AS r
                INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = r.aid
                $RANDOFF
                AND approved = 'YES'";

        $result = cpg_db_query($query);

        list($count) = mysql_fetch_row($result);
        mysql_free_result($result);

        $query = "SELECT pid
                FROM {$CONFIG['TABLE_PICTURES']} AS r
                INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = r.aid
                $RANDOFF
                AND approved = 'YES'
                ORDER BY RAND()
                $limit";

        $result = cpg_db_query($query);

        $pidlist = array();

        while ( ($row = mysql_fetch_assoc($result)) ) {
            $pidlist[] = $row['pid'];
        }
        mysql_free_result($result);

        sort($pidlist);

        $select_columns = implode(', ', $select_column_list);

        $query = "SELECT $select_columns
                FROM {$CONFIG['TABLE_PICTURES']} AS r
                INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = r.aid
                WHERE pid IN (" . implode(', ', $pidlist) . ")";

        $rowset = array();

        // Fire the query if at least one pid is in pidlist array
        if (count($pidlist)) {

            $result = cpg_db_query($query);

            while ( ($row = mysql_fetch_assoc($result)) ) {
                $rowset[-$row['pid']] = $row;
            }

            mysql_free_result($result);
        }

        if ($set_caption) {
            build_caption($rowset);
        }

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

        return $rowset;
        break;
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: don't show some albums on 'random pictures'
« Reply #4 on: August 06, 2012, 07:08:10 pm »

Please also post a link to your gallery, as I guess that you're talking about the sections on your main page (I assume all section below the random block are affected). Instead of creating an array and using a loop I suggest to use something like
Code: [Select]
$RANDOFF = $RESTRICTEDWHERE." AND r.aid NOT IN (699, 700) ";
Logged

alexandre596

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: don't show some albums on 'random pictures'
« Reply #5 on: August 06, 2012, 07:50:57 pm »

that sure looks better
and yes, the latests pictures is below the random, the link of my gallery
http://seyfried-amanda.com/galeria/

thank you
Logged
Pages: [1]   Go Up
 

Page created in 0.03 seconds with 19 queries.