KQL Plugin: Structure FilterBy Method on pageField

I want to filter a structure field based on the ID of a page selected from one of the pages contained in the structure. The query should work like this:

query: page.specialExhibitions.toStructure.filterBy('chesas.toPage.id', '==', ${slug} ),

In this case, chesas is the pages field that returns a page. Slug is dynamic, based on the route. The page is a child of another page (query: 'page("projects").children').

Is it possible to filter by the page content (in my case, its ID)?

If this works, then this should read page.chesas.toPage.id

Unfortunately, that doesn’t work… to specify further, ‘chesas’ is present in the blueprint as a ‘Pages Field’ within the structure:

              type: structure                
                  label: Chesa
                  type: pages
                  query: site.page('chesas').children
                  multiple: false
                  type: text
                  label: Titel

I also tried ‘structureItem.chesas.toPage.id’ but that didn’t work either. If I would filterBy title

filterBy('title, '==', 'Some Title' )

would work… So in my logic …

filterBy('chesas.toPage.id', '==', ${slug} )

…should actually be correct?

Sorry, didn’t look closely. In php, your filter would have to look like this:

<?php $res = $page->specialExhibitions()->toStructure()->filter(fn($item) => $item->chesas()->toPage->uuid()->toString() === 'page://X8f4TmwMEq8qZAcR');

Since you cannot do this in query language, you need a custom method here.

The pages field stores the uuid if not otherwise defined.

What is ${slug} in this context?

Ok I see… Many thanks for your reply.
${slug} is the route f.ex. /projects/subpage and equivalent to the page.id.
I use it to dynamically fetch the content:

query: `site.page("${slug}")`,

…and since parts of the data comes from other pages i would like to fetch just this certain data in the structure field. (instead of fetching the whole structure data and then filter the collection using JS)