don't show some albums on 'random pictures' don't show some albums on 'random pictures'
 

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]

Main Menu

don't show some albums on 'random pictures'

Started by alexandre596, August 05, 2012, 09:37:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

alexandre596

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

Αndré

Open include/functions.inc.php, find
case 'random': // Random files
and below, add something like
$RESTRICTEDWHERE .= ' AND r.aid != 123 ';

alexandre596

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


    $albumoff[] = 699;
    $albumoff[] = 700;

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


thank you so much <3

alexandre596

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)


        $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;

Αndré

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
$RANDOFF = $RESTRICTEDWHERE." AND r.aid NOT IN (699, 700) ";

alexandre596

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