Panel, show a filtered collection of subpages of another page

Given a panel structure similar to this…


…I want to show, in ‘artist-item’, a list of all ‘exhibition-item’ pages whose ‘participatingartists’ tags field contains the ‘artist-item’ page’s title.

So, in the ‘artist-item’ panel page whose title field is ‘Kirby Person’, I want to show all ‘exhibition-item’ pages whose ‘participatingartists’ field contains ‘Kirby Person’.

I figured this would be done with a pages section, but I only see how to set up the parent of the pages section, but not how to filter the pages by field contents.

I am refering of course to a query akin to what we can do with the image:

  query: page.image.findBy("name", "cover")

I also looked at the pages field, but I don’t want the user to select anything, I want only to show the pages, and that the user can click on them to open them of course.

Or is my only solution ?

Thank you

Short answer: Yes.
Slightly longer version: A standard pages section doesn’t have a query option. As you already said, there is only a parent options, with the possibility to filter by template and status, nothing else.


I see this is already on the whishlist kindof, although not sure about the title:

Yep, query option for pages and files sections has been on the wishlist for ages. Not all wishes come true, though, or not so quickly :woman_shrugging:

1 Like

Nevertheless @texnixe, could you help me with the query for the pages display section please?

I tried:

query: page('exhibitions').children.sortBy('openingdate','desc').filterBy( 'artists', 'in', page.title, ',') 

trying to emulate this example, but that does not seem to work

the logic was to find children of the exhibitions page, whose ‘artists’ tag field, contains the title of the page we are in.

The code looks backwards, as if it tries to find the tags in the title not the other way around, but I presume the first argument must be a field from the looped pages. I also am unsure if I can refer to the actual page’s title as such. Always a bit lost with query language and filtering.


Is your field name correct, in your first post it was participatingartists?

Yes, I renamed it in the example for the sake of clarity:

					label: Participating Artists 
					type: tags 
					options: query
						fetch: site.find('artists').children
						text: "{{ page.title }}"
						value: "{{ page.title }}"
					required: true

And in expects an array, not a string. So we don’t want in here:

filterBy( 'artists', page.title, ',')
1 Like

Yes! that works, thank you!