Retrieving all children (of a particular template type)

(Image attached to help contextualise what I’m trying to do)

I’ve got a content type, Series. In the attached image, “Thor” is a Series.
Inside the Series, there are Collections and/or Volumes.

A Volume is an organisational construct. So, in this instance (although not visible in the attached image), there are two Collections inside “The Thor War”.

A Collection is a single book or issue or edition. They may or may not be contained inside a Volume. In the attached image, “The Black Galaxy Saga” is a collection which isn’t currently part of a Volume.

What I’m trying to do is retrieve all Collections inside the current Series, whether they’re inside a Volume or not.

In the Series blueprint, any query I write to find all Collections breaks things, and I get the blueprint’s empty message.

What am I missing with this…?

Thanks in advance - much appreciated!

Series.yml

title: series

status:
  draft:
    label: Draft
    text: The series is still in draft mode. It can only be seen by editors with Panel access.
  unlisted:
    label: In Review
    text: The series is online and can be visited with the direct URL. The team must still give the final go to publish it.
  listed:
    label: Published
    text: The series (and any Collections within it) can be viewed on the live site.

columns:
  - width: 3/3
    sections:
      seriesCollections:
        type: pages
        label: Collections
        template: collection
        status: all
        layout: cards
        size: small
        sortBy: modified desc
        limit: 10
        info: "{{ page.Publicationformat }}"
        image:
          cover: true
          back: "linear-gradient(to bottom, rgba(255,255,255,0.5) 0%, rgba(240,240,240,1) 100%)"
        empty: No collections yet

      seriesVolumes:
        type: pages
        label: Volumes
        templates: 
          - volume
        layout: list
        size: small
        sortBy: modified desc
        limit: 5
        image:
          cover: true
          back: "linear-gradient(to bottom, rgba(255,255,255,0.5) 0%, rgba(240,240,240,1) 100%)"
        empty: No volumes yet

Where do you want to use the query, in the seriesCollections section?

query: page.index.template('collection')

should do the job

It’s defaulting back to the empty message again…
I’m looking for a way to debug blueprints now.

Please post the blueprint with the query

title: series

status:
  draft:
    label: Draft
    text: The series is still in draft mode. It can only be seen by editors with Panel access.
  unlisted:
    label: In Review
    text: The series is online and can be visited with the direct URL. The team must still give the final go to publish it.
  listed:
    label: Published
    text: The series (and any Collections within it) can be viewed on the live site.

columns:
  - width: 3/3
    sections:
      seriesCollections:
        type: pages
        label: Collections
        template: collection
        query: page.index.template('collection')
        status: all
        layout: cards
        size: small
        sortBy: modified desc
        limit: 10
        info: "{{ page.Publicationformat }}"
        image:
          cover: true
          back: "linear-gradient(to bottom, rgba(255,255,255,0.5) 0%, rgba(240,240,240,1) 100%)"
        empty: No collections yet

      seriesVolumes:
        type: pages
        label: Volumes
        templates: 
          - volume
        layout: list
        size: small
        sortBy: modified desc
        limit: 5
        image:
          cover: true
          back: "linear-gradient(to bottom, rgba(255,255,255,0.5) 0%, rgba(240,240,240,1) 100%)"
        empty: No volumes yet

  - width: 3/3
    fields:
      seriesDivider:
        type: line
      metaData:
        type: headline
        label: About the series

  - width: 2/3
    sections:
      seriesThis:
        type: fields
        fields:
          description:
            label: Series description
            type: writer
            toolbar:
              inline: false
            required: false
            width: 2/2

          yearStart:
            label: Publishing started
            type: number
            required: false
            #default: {{ date.year }}
            placeholder: Year
            step: 1
            width: 1/2

          yearEnd:
            label: Publishing ended
            type: number
            required: false
            placeholder: Year
            step: 1
            width: 1/2

  - width: 1/3
    sections:
      seriesHeroImage:
        type: fields
        fields:
          hero:
            label: Hero image 
            type: files
            layout: cards
            query: page.images
            image:
              cover: true
              back: "linear-gradient(to bottom, rgba(255,255,255,0.5) 0%, rgba(240,240,240,1) 100%)"
            max: 1 
            multiple: false 



      seriesAvailableImages:
        type: files
        label: Available images
        image:
          cover: true
          back: white        
        empty: Upload an image to represent {{ page.title }}



And the template name is correct?

…I believe so? If I comment out the query, then the ‘seriesCollections’ section starts showing items again, which suggests that the template “collection” is correct.

If I wanted to fact-check that assumption, I would look for site/templates/collection.php right?

Hm, weird. The query is correct, and section queries should work from Kirby 4.0.0. I also tested the query in a 4.3.0 Starterkit.

I really don’t know if this is a thing that’s applicable in this situation… but yesterday I saw a comment on another support ticket… “keep in mind that the parent must be a unique page. You can’t have a collection of pages as a parent”

Is that possibly relevant in this situation…?

No, in that thread, the user used a query that returned a collection of pages on the parent property.

The query property, however, has to return a collection of pages.

Just wanted to show the folder structure for this project… just in case the nesting of the content types was potentially a factor in all of this weirdness.

I’ve tried to load Collections into site.yml as well, and I’m getting that same “No collections found” message again on another blueprint. So this code has been pasted into site.yml, directly from volume.yml – which does display the collections correctly.

extract from Site.yml

  - width: 3/3      
    sections:
      siteCollections:
        type: pages
        label: Collections
        template: collection
        layout: cards
        size: small
        sortBy: modified desc
        limit: 10
        text: "{{ page.title }}"
        info: "{{ page.Publicationformat }}"
        image:
          cover: true
          back: "linear-gradient(to bottom, rgba(255,255,255,0.5) 0%, rgba(240,240,240,1) 100%)"
        empty: No collections yet

Hi, that last sitecollections example does not have a query?

But looking at your folder structure, I can see those collection items are drafts, not published pages. So page.index does not cover them, you would have to use page.index(true) to include drafts.

Well observed! As an explanation… volume.yml has been correctly returning Collections without using a query. And so it got copied over as-is to site.yml.

I think this suggests that the weirdness isn’t specifically my Series.yml file.

To that point, I’ve updated Site.yml with your suggestion, @moonwalk
I’m still getting the empty state of No collections found

Updated extract from site.yml

  - width: 3/3      
    sections:
      siteCollections:
        type: pages
        label: Collections
        query: page.index(true).template('collection')
        layout: cards
        size: small
        sortBy: modified desc
        limit: 10
        text: "{{ page.title }}"
        info: "{{ page.Publicationformat }}"
        image:
          cover: true
          back: "linear-gradient(to bottom, rgba(255,255,255,0.5) 0%, rgba(240,240,240,1) 100%)"
        empty: No collections yet

In site.yml, this query does not make sense, because there is no page reference. So would have to be

query: kirby.page('thor').index(true).template('collection')

That worked! :star_struck:
Which then means I can use query: site.pages.index(true).template('collection') to fetch all Collections from all Series. Amazing!

Okay, so that then means my next puzzle is what does it mean for the other queries which haven’t been working on the other blueprints…?

So, it appears that the index(true) piece was what I needed. I’ve been back through the various Blueprints, and I’m now getting all of the Collections, as expected.