Blueprint section parent query

hi!

wondering if beside the find method

parent: site.find("notes")

you can do other queries, eg site.template or site.filterBy?

parent: site.template("notes")

having to manually set an hardcoded uid is not always possible.

thanks and congratulations for the launch of v3!

I was wondering that too!

But I think this would need a query: option besides the existing parent: as your filterBy example would lead to multiple parent elements.

I found this issue/idea: https://github.com/getkirby/ideas/issues/28

EDIT:

Seems like something like this is already possible:

pages:
  type: pages
  headline: Notes
  parent: site.index.findBy("template", "notes")

that would be great indeed! thanks for sharing.

i tried your suggestion, but it’s not working for me. did you try it yourself?

Try this

parent: site.index.findBy("intendedTemplate", "notes")

As a side note, keep in mind that the parent must be a unique page. You can’t have a collection of pages as a parent

If you have multiple, make sure you turn it into one, e.g.

parent: site.children.first

Using findBy() as suggested above should be fine as well, it always returns a single element (i.e. the first element it finds).

Ah, didn’t know that. That’s good to know.

But what if I had 3 pages with same template and want a reusable pages section, displaying their individual subpages? Wouldn’t I have to hardcode that for each parent?

@daybugging Well, you can have a reusable section, but would have to extend this section for each instance with another parent where needed. Works the same way as with extending the headline or any other feature of that section, check out the Starterkit for examples.

1 Like

@daybugging if you want the direct subpages you don’t need to set parent. The pages section shows you the direct children by default