Image query: page.cover not working / only working with specific blueprint name?


I just got started switching from working with Kirby 2 to Kirby 3. To practice, I started working on a small, simple portfolio site, but I’m running into a strange issue when trying to set up a »Projects« page.

Note: I’m basing most of my blueprints on the Kirby 3 Starterkit, because it comes with a lot of handy things.

The blueprint for my »Projects« page look like this:

title: Projects

icon: 📷

    type: pages
    headline: Published Projects

    size: tiny
    info: "{{ page.images.count }} image(s)"
    layout: cards

    template: project

    empty: No projects yet

      query: page.cover
      cover: true
      ratio: 5/4

Notice how I am using the page.cover query from the Starterkit albums.yml blueprint.

The corresponding »Project« blueprint looks like this:

title: Project

icon: 🎆

  draft: true
  listed: true

  - width: 2/3
        type: files
        layout: cards
        template: image
        info: "{{ file.dimensions }}"
          ratio: 5/4
          cover: true
        min: 0
        size: small

  - width: 1/3
        type: files
        multiple: false
        type: text
        type: textarea
      tags: true

Again, this is pretty much a copy of the Starterkit’s album.yml.

However, when I create a project page (as a subpage of »Projects«) a couple things from the blueprint fail to work. 1) The cover image is not being displayed (instead its just the icon defined in the blueprint) and 2) the empty text defined in the blueprint does not show up in the section (instead it just says »No pages yet«).

When there are no projects yet, the empty text should say »No projects yet«

An image is uploaded to the project + set to be this project’s cover…

…but it does not show up in the section of the project’s parent.

However, and this confuses me, when I set the template for the pages of »Projects« to album and rename project.yml into album.yml, the cover shows up just fine:


Can someone help me understand what is going on here and why renaming my blueprint to »album« instead of »project« fixes the cover issue?

Placeholder text not working is a bug that will be fixed in 3.0.3.

  1. problem: it will work if you do this:
    (took me a while to get what the problem was)
  query: page.cover.toFile

The reason is, that cover doesn’t refer to a filename, but a page method called cover. The album page uses a page model with a cover method that returns the image selected in the cover if if it exists, or the first file. Your new page doesn’t have such a page model.

This is the model /site/models/album.php


class AlbumPage extends Page
    public function cover()
        return $this->content()->get('cover')->toFile() ?? $this->image();

Thanks :slight_smile: Just read up on page models, makes perfect sense :ok_hand: