Why can I not query my pages in my site.yml

Im trying to query for pages with a filterBy. What I have in my site.yml is this:

    label: Videos
    icon: video
        type: pages
        parent: kirby.page('videos')
        max: 2
        layout: cards
        info: "{{ page.kennung }}"

What works is querying for the parent element with kirby.page(‘videos’).
What doesn’t work is the max line or when I try to query the pages like so:

query: site.find('videos').children.filterBy('category', 'myCategory', ',')

After Searching through the forum I also tried to use a custom collection and then query for that:

return function ($site) {
   return $site->find('videos')->children()->filterBy('category', 'myCategory', ',');

which does indeed return the pages I want when I test it in a template.

Is there something I am missing?

Section don’t have a query property, you can only set a parent and filter by template via the templates. property.

Other filters are not possible.

There is a plugin that lets you query pages but then you cannot add pages anymore: https://getkirby.com/plugins/rasteiner/pagesdisplay

The max property should work. Will test.

1 Like

Okay, got that! Thank you. So I guess my best option would be having the category as a parent page of the video-pages and then querying with the parent option? Is that generally the way to go with categories? Sorry if that’s a bit off topic now.

Sorry, I missed your answer easlier.

You could create a custom section that supports filtering by category and at the same time allows adding new items. However, that would probably also be a bit strange, unless you pre-define the category that is assigned to a new page when the page is created to make sure that it ends up in the section in which it was created.

Using category parent pages is probably the better option is this case, if having different sections per category is that important.