Forum
Filtering Gallery by related field
Hi Guys,
I am trying to setup a page that filters a gallery based on a related field, based on a slug of the page. When I do a showall I get the following;
url_0 /artists/catherine-t
url_artist catherine-t
url_1 catherine-t
perch_page_path /artists
domain //localhost:8080
url //localhost:8080/artists/catherine-t/
description
albumID 1
albumTitle Supershoes
albumSlug supershoes
albumOrder 1
albumDynamicFields {"description":{"_flang":"textile","raw":"","processed":""}}
imageCount 2
perch_description
pair_number 1
_title 1
artist
Array
(
[0] => 2
)
sponsor
Array
(
[0] => 39
)
imageID 1
imageAlt Super Kendal
imageSlug 02-superkendal
imageOrder 1
imageDynamicFields {"pair_number":"1","_title":"1","artist":["2"],"sponsor":["39"]}
imageStatus active
imageBucket default
perch_pair_number 1
perch__title 1
perch_artist
Array
(
[0] => 2
)
perch_sponsor
Array
(
[0] => 39
)
full /cms/resources/02-superkendal-w1200h900.jpg
full-w 1200
full-h 800
full-id 1
full-key full
thumb /cms/resources/02-superkendal-w150h150.jpg
thumb-w 150
thumb-h 150
thumb-id 2
thumb-key thumb
thumb_2x /cms/resources/02-superkendal-w300h300.jpg
thumb_2x-w 300
thumb_2x-h 300
thumb_2x-id 3
thumb_2x-key thumb_2x
original /cms/resources/02-superkendal.jpg
original-w 3888
original-h 2592
original-id 4
original-key original
admin_thumb /cms/resources/02-superkendal-w80h80.jpg
admin_thumb-w 80
admin_thumb-h 80
admin_thumb-id 5
admin_thumb-key admin_thumb
admin_preview /cms/resources/02-superkendal-w180.jpg
admin_preview-w 180
admin_preview-h 120
admin_preview-id 6
admin_preview-key admin_preview
_id 1
perch_item_first true
perch_item_zero_index 0
perch_item_index 1
perch_item_rev_index 2
perch_item_rev_zero_index 1
perch_item_odd
perch_item_count 2
perch_namespace perch:gallery
I am trying to filter on the perch_artist section as this is the related field where you choose the artist for that gallery item.
The page is displayed based on the artists slug. E.G /artists/catherine-t/
I can do this with perch_content_custom and works nicely like so;
perch_content_custom('Stories', array(
'page' => '/stories',
'template' => 'stories/_teaser',
'filter' => 'artist.artist_slug',
'match' => 'eq',
'value' => perch_get('artist'),
));
But how can I do this with the Galleries? I have tried this....
perch_gallery_album_images('supershoes', array(
'template' => 'a_list_image',
'filter' => 'artist.artist_slug',
'match' => 'eq',
'value' => perch_get('artist'),
));
Thanks, Terry
Can you show us your template?
Sure;
image.html template;
and the a_list_image.html template
I suspect this may not work with the Gallery app due to its vintage.
Would you recommend another approach then? Collection or List/Details page perhaps?
Or can I do something with the gallery app but a little more manual PHP code?
Any thoughts on this Drew?
Sorry, it's been the weekend.
I'm not sure I can really make a recommendation, as I don't know your aims and objectives. We can help if you hit problems with the software, but how you structure the site is really your call.
Thanks Drew. I understand what you are saying. I guess what I was getting at is it likely that the gallery would be extended to include this functionality. Or now we have runway/collections etc, do you guys see the gallery as a redundant/dead app that will unlikely undergo any further development. So in that case based on the direction Perch are moving in, would it be of your opinion to approach it differently and not use the gallery app.
In this instance, my aim is to pull all related images from a gallery into a particular artists page. This page also pulls in related stories from a list/details page too (which works nicely).
The plan is that Gallery will be deprecated and the functionality rolled directly into Assets.
Thanks Drew. I have decided to change this into a Collection. All functioning as it should now.