forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: alexandre596 on August 05, 2012, 09:37:04 pm

Title: don't show some albums on 'random pictures'
Post by: alexandre596 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
Title: Re: don't show some albums on 'random pictures'
Post by: Αndré 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 ';
Title: Re: don't show some albums on 'random pictures'
Post by: alexandre596 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
Title: Re: don't show some albums on 'random pictures'
Post by: alexandre596 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;
Title: Re: don't show some albums on 'random pictures'
Post by: Αndré 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) ";
Title: Re: don't show some albums on 'random pictures'
Post by: alexandre596 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