Query how to select a page?

I have the following Blueprint. I want the editor to be able to select all shop child pages, that use the product_template template.

selected_consumer_products:
	label: Selected consumer products to display
	type: pages
	query: shop.children.template("product_template")

I’ve been looking at this page

But not sure how to select a particular page?

Do I have to write this?

query: site.find('shop').children.template("product_template")

I would create a collection and do your filtering there. You need to filter on the template used for the pages.

You can call on that collection in the query option in the blueprint anywhere you need that collection.

A query like this might also work:

query: site.find('shop').children.filterBy("template", "product_template")

Thanks. This version seems to work

query: site.find("shop").children.template("product_template")

so it looks like you have to go from site > find the “shop” page > children > using a template called “product_template”.

I’m confused because this page seems to say this is how to query the template

template('note')

But on this page

we have to use

filterBy('template', 'in', ['template-a', 'template-b'])

Both do the same, template is just a shortcut to query a single template. You can find it both in the documentation: $pages->template() | Kirby CMS

I wonder where you got that from, we have loads of examples in the docs how to query a single page

Afraid I don’t understand that documentation. $pages->template() | Kirby CMS

So to query a template I can simply write template("product_template") ?

Afraid I’ve looked in the docs but can’t find how to query/select a page. Do I have to use the find thing? site.find("shop") ?

query: site.find("shop").children.template("product_template")

That’s one way.

page('shop')
kirby.page('shop')

are alternatives.

No, you cannot simply call the method as such, you need to call it on a $pages collection, e.g. page(‘shop’).children.template(‘sometemplate’).

Please get familiar with the basics of Object Oriented Programming and Kirby’s classes. Otherwise you will have a hard time to ever understand the documentation.

Thanks.

This works
page(‘shop’).children.template(‘product_template’)

I’ll find some time to look at OOP in PHP | Kirby CMS.