ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Override default Photo gallery catgeory display

November 24, 2008 5:17pm

Subscribe [1]
  • #1 / Nov 24, 2008 5:17pm

    Tim Smith

    15 posts

    I need to have a photo gallery that only displays one category at a time.

    It must not display all categories if the specified category does not exist.
    i.e. if category id 7 does not exist http://domain.com/index.php/gallery/category/C7 must display nothing rather than all categories.


    It’s quite straightforward to make http://domain.com/index.php/gallery/category not display anything by checking if segment_3 exists. But what I’d like to know is how to force the photo gallery entries to only be those from categories=segment_3.

    Anyone got a recommendation?

  • #2 / Nov 25, 2008 8:56am

    Tim Smith

    15 posts

    The only way I’ve got is to use some php to remove the “C” from the photo gallery category id in segment 3 using php.

    <?php 
    global $IN;
    $seg3 = $IN->SEGS[3];
    $s1=substr($seg3,0,1);
    if ($s1=="C" || $s1=="c"){
        $cat_id=substr($seg3,1);
    } else {
        $cat_id=$seg3;
    }
    ?>
    {exp:gallery:entries gallery="{gallery_name}"  category="<?php echo $cat_id; ?>" orderby="title" sort="asc" columns="4" rows="3"}

    Any better ideas?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases