Creating pages via a pages section with query

I have a site with a central news-folder that I want to access from another page via a pages section that works fine so far. This is my page blueprint:

      news:
        type: pages
        template: news
        info: "{{ page.pub }}"
        query: site.find('news').children
        limit: 10

So far so good. But when I try to create a new page/entry in the news via this page, the news-entry gets stored as a subpage of the current page. I was expecting the pages section to store new pages in the central news-page news where the existing entries are actually queried from.

(Apart from that the query site.find('news').children apparently only returns published children.)

How can I do this? Is it even possible?

Thanks for any hints!

An obvious solution could be to move the news pages to the page with the pages section and not use a query. Depending on the situation of course.

Alex

Not sure if I fully understand the problem but you should either look into the parent property of your pages section or check if you are actually looking for pages field functionality.

Many thanks and sorry for crossposting here and at discord … I’m always confused by having sections and fields with mostly the same possibilities, but not quite.

The parent-option mentioned by the other Nils™ is likely what I’m looking for, but what was too obvious to find :D.

Using

parent: site.find('news')

instead of

query: site.find('news').children

is what I was looking for. Don’t know why I was tripping in the query-rabbithole. Thanks to both Nilses!

1 Like

Yeah, it’s complex because field and section look and behave similar but not the same. The query option is new in K4 and addresses the need for “display section”. I guess the team will add more documentation in the long run how to properly set up parent and query together.

… the other Nils™ …

As long as it’s a Nils™, everything is fine :smiley:

Looks like I don’t even need the query: option. parent: seems to do all I wanted.