Can I write "parent: site.find('posts').limit(10)" in a blueprint?

Hi,

I tried to get and limit the number of pages in panel section.

In my blueprint, I get my pages with parent: site.find('posts') and it works well but if I add limit() or filterBy() like this parent: site.find('posts').limit(10) I’ve got the error Undefined property: Kirby\Cms\Field::$data

 sections:

       # section pages listed
       pagespost:
          headline: Resources
          type: pages
          status: listed
          parent: site.find('posts').limit(10)
          info: "{{ page.publication }} / {{ page.template }} {{ page.sponsor }}"
          template: post

Can I write “parent: site.find(‘posts’).limit(10)” in a blueprint?

No, the syntax doesn’t make sense, because that’s not a collection but a page. The syntax is like in your template, to use limit, you would use

$site->find('posts')->children()->limit(10)

But the parent option wants a page, not a collection.

You can use the limit option to display only x items per pagination “page”, but you will get the pagination underneath. But if you really only display 10 items but there are more, you won’t be able to access the other pages anymore unless you know the direct link, so that’s probably not such a good idea, anyway? But I don’t know your use case.

Ok I understand now.

So may I use a query instead?

Something like:

sections:

     # section pages listed
     pagespost:
     headline: Resources
     type: pages
     status: listed
     options: query
     query: site.find('posts').children.limit(10)
     info: "{{ page.publication }} / {{ page.template }} {{ page.sponsor }}"
     template: post

The code above doesn’t generate error but return nothing :-/

A pages section doesn’t have a query option…

Maybe this plugin can do what you want: https://github.com/rasteiner/k3-pagesdisplay-section

Thanks @texnixe and @moeli I will try with the plugin

Note that you can’t add pages when using the plugin, that may or may not be what you want…

That’s by the way the reason why filtering was removed from sections for the time being, because it can easily lead to pages being created by afterwards being inaccessible.

Ok noted!

This plugin is perfect for my use case :+1: