Forum

Thread tagged as: Question, Gallery

Gallery category filtering

I'm trying to filter galleries by category, but my code below displays the gallery in first position in the album list. What am I doing wrong?

                <?php 
                    perch_gallery_albums(array(
                    'template' => 'homepage_album_image.html',
                    'category' => 'gallery/featured/',
                    'image' => true,
                    'count'=>1
                )); ?>
                </article>

Album template...

<h2><perch:gallery id="albumTitle" type="text" label="Title" size="l" /></h2>
<perch:gallery id="description" type="textarea" label="Description"  editor="tinymce" html="true" order="1" size="m" />
<perch:gallery id="supplemental-description" type="textarea" label="Supplemental Description"  editor="tinymce" html="true" order="2" size="m" />
<perch:categories id="gallery-catagories" label="Catagory" set="gallery" display-as="checkboxes" />

Thanks

Mark Phoenix

Mark Phoenix 0 points

  • 6 years ago

Mark, With count => 1 your only going to get a single album returned.

What are you expecting to get?

RK

Hi Robert.

I do just want to display a single album, the code is for a featured gallery area on the home page. I want my client to be able to choose which one appears there by assigning it the category 'featured'.

Mark, The code you have provided above should be doing the following...

Showing the 1st album image (I am assuming from template name) with the category gallery/featured

It that whats happening? and how is this different from your expected result?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Gallery predates the categories functionality, so the category option won't work here.

Ah, okay thanks Drew. Could I achieve the desired result using perch_content_custom()?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Quite possibly - can you outline what you're trying to do?

Sure thing. I'm basically trying to filter galleries based on categories.

I have an area on the home page for a featured gallery (which just shows a title, cover image and description as set out in the template up top of this thread).

At the moment the code snippet up top displays the gallery in the first position in the album list.

But I'd like my client to be able to select which one is displayed by assigning it a category, such as 'featured'.

Is there a way to achieve that with perch_content_custom()?

Ta.

Drew McLellan said:

Gallery predates the categories functionality, so the category option won't work here.

Sorry Mark, it's been quite some time since I have used gallery. If categories worked in this app, it would give the results as I explained, but hey... I've learned something too.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Probably the way to do it is to stick with Gallery, but add a 'featured' field to filter on rather than using categories.

Aha. Thanks Drew!

Robert Ketter said:

Drew McLellan said:

Gallery predates the categories functionality, so the category option won't work here.

Sorry Mark, it's been quite some time since I have used gallery. If categories worked in this app, it would give the results as I explained, but hey... I've learned something too.

No worries & thanks for pitching in. Every day's a school day and things.