Switch between different query options or parents conditionally


I am making a blueprint snippet where there’s a page field selecting from a specific template. I would like to make an option to switch between searching the children of the current page, or the entire site.

Two different queries I would like to be able to switch between:

query: page.children.filterBy('template', 'in', ['artifact'])
query: site.index.filterBy('template', 'in', ['artifact'])

I was thinking of implementing this using a simple toggle field, but I am not sure if this is easily done the only solution I could find so far would be similar to the link below, which might be a bit much for what I am looking for: Programmatically change the content of the file field

Another option would be if it’s possible to switch between page.children and site.index through some way, or less clean solutions like duplicating the field and displaying the non-empty one through PHP or duplicating the entire block.

I would love to hear if you have any good suggestions for this!

The problem is that you want this to happen real time. And the only way this can work out of the box, is using two fields with a when query. The downside is that these fields then have different names and you’d have to render them conditionally in the frontend. But definitely the easiest solution for this requirement

Thank you!

I believe that’s the solution I’ll go for as it’s probably least complicated and still rather clean to use :slight_smile: