Query for blueprint, field to get pages with different types of templates

I’m trying to add a field of type page, which should include my pages of type product or project.

I already tried a couple of things like:

First try

    references:
        label: References
        type: pages
        multiple: true
        query: site.index.template(['project', 'capability']).visible()

Second try:

    references:
        label: References
        type: pages
        multiple: true
        query: site.index.template('in', ['project', 'product']).visible()

Third Try:

    references:
        label: References
        type: pages
        multiple: true
        query: site.index.filterBy('template', 'in', ['project', 'product']).visible()

Fourth Try:

    references:
        label: References
        type: pages
        multiple: true
        query: site.index.filterBy(['project', 'product']).visible()

Fifth try:

    references:
        label: References
        type: pages
        multiple: true
        query: site.index.filterBy('template', 'project').filterBy('template', 'product').visible()

And a couple more similar to those above does somebody know how to do it?

query: site.index.template('project', 'product').listed

visible is deprecated, but there shouldn’t be parenthesis after it, in any case.

@texnixe thanks for your answer but it doesn’t work

Sorry, missed the s:

query: site.index.templates('project', 'product').listed

@texnixe thanks, but now I get all pages listed :frowning: , is it a bug?

Hm, I would have expected this

query: site.index.filterBy('template','in', ['note', 'album'])

to work, but it throws an error…

Maybe use a custom collection and query that, then.

I created an issue on GitHub, because I think it’s a bug.

Currently trying to get this to work. Could you post an example?

Basically you put that query into a collection: https://getkirby.com/docs/guide/templates/collections

// /site/collections/yourname.php
return function ($site) {
    return $site->index()->filterBy('template', 'in', ['note', 'album']);
};

and then in the blueprint

query: kirby.collection('yourname')
4 Likes