Forum

Thread tagged as: Question, Addons, Gallery

How do I display all galleries apart from one on a certain page?

I'm using the Gallery app to display various images on a page of my site, on another page I would also like to display all of these images except for one specific gallery.

Is there an easy way to do this?

Cheers

Adtrak LLP

Adtrak LLP 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can use a filter for that:

perch_gallery_albums(array(
    'filter' => 'albumSlug',
    'match' => 'neq',
    'value' => 'album-you-dont-want',
));

Thanks a lot for that! I was pretty close - just missed off album in front of Slug!

At the moment it's only displaying one image from the Galleries though, I'm assuming that's something to do with the template file I'm using?

It looks like this at the moment:

    <perch:before><ul></perch:before>
    <li class="boxer">
        <a class="fancybox" href="<perch:gallery id="main" />">
            <img src="<perch:gallery id="small" />" alt="<perch:gallery id="imageAlt" />" />
        </a>
    </li>
    <perch:after></ul></perch:after>

    <perch:gallery id="albumTitle" type="text" label="Name" size="l" />
    <perch:gallery id="description" type="textarea" label="Description" editor="markitup" textile="true" order="1" size="m" />
Drew McLellan

Drew McLellan 2638 points
Perch Support

perch_gallery_albums list the albums. Do you want to list the images instead?

I need to list the images within the albums, as well as the album titles and the description text for each.

Drew McLellan

Drew McLellan 2638 points
Perch Support

How are you doing that at the moment?

I currently just have the code I posted above, and then on the page I have -

<?php perch_gallery_albums(array(
     'template' => 'recent-projects.html',
     'image' => true,
     'filter' => 'albumSlug',
     'match' => 'neq',
     'value' => 'testimonials',
)); ?>

Can anyone help me with this?

Cheers

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you're listing albums then you get one image per album. If you want to list all the images, use skip-template to get the album slug and then loop through requesting the images for the album.

OK cheers, so should it look like this?

<?php perch_gallery_albums(array(
     'skip-template' => true,
     'image' => true,
     'filter' => 'albumSlug',
     'match' => 'neq',
     'value' => 'testimonials',
)); ?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Right, except you need to catch the output:

$albums = perch_gallery_albums(array(
     'skip-template' => true,
     'image' => true,
     'filter' => 'albumSlug',
     'match' => 'neq',
     'value' => 'testimonials',
));