Querying pages by template does not show any pages

Hi there,

I have a pages field in my site.yml blueprint, where I would like to be able to choose pages with the article template. I tried to set this up, but it does not let me select any pages. The article pages are actually two levels down, so I thought this should work via querying the site.index.

Here is my pages field:

featured:
  label: Featured
  type: pages
  layout: cards
  query: site.index.filterBy('template', 'article')

There are listed pages with the article template (see screenshot):
20220217-154820_Screenshot_SublimeText

yet, when I click the add button on the pages field, it tells me there is no pages:
20220217-154935_Screenshot_folgen.test

Is there something else I am missing?
This is in Kirby 3.6.2

Thanks!

To be able to filter by template, the template has to actually exist in the /site/templates folder. Otherwise use intendedTemplate instead.

1 Like

Oh my, I thought I was going crazy here. Thanks a lot, that was it.
Also, I finally understand what intendedTemplate is supposed to mean.

hi @texnixe, i have the same problem, but in this case i have the files in the template directory.
i am upgrading an old kirby 2 to kirby 3, i used the script to optimize the name of folders in /content, and everything was ok.

When i was starting to “re-organizing” blueprints, i made a new site.yml with this code:

sections:
  #
  pages:
    headline: Pagine
    type: pages
    templates: 
      - home
      - about
      - works
  #
  pages__utility:
    headline: Pagine di servizio
    type: pages
    template: error

i have already put error.php and home.php in /site/templates folder, but i cannot view the pages in panel…

But if i try to create a new page, then the templates i can use are the right ones [so the problem it’s that i cannot view the existing pages].

If i try to create a page with the name of the template then the panel display this message [that means the pages already exist, but i cannot view them…]:

Can anyone help me?

ps: i tried also this, but it doesn’t work too:

query: site.index.filterBy('template', 'home')

Could you please post the complete site.yml, there seems to be something wrong.

Sure:

site.yml

title: FF3300
unlisted: true

tabs:
  #
  pages: tabs/site__pages
  #
  data_utility: tabs/site__utility

/tabs/site__pages.yml

label: Pagine
icon: globe

sections:
  #
  pages:
    headline: Pagine
    type: pages
    templates: 
      - home
      - about
      - contact
      - spin-off
      - works
      - clients
      - people
  #
  pages__utility:
    headline: Pagine di servizio
    type: pages
    templates:
      - search
      - error
      - default
      - policy

/tabs/site_utility.yml

label: Utilità
icon: cog

sections:
  #
  data_utility:
    headline: Utilità dati
    type: fields
    fields:
      #
      ## Loghi
      #
      site__headline:
        label: Site management
        type: headline
      #
      logo:
        label: Logo Header
        type: files
        max: 1
        help: Carica qui il logo in formato .SVG
      #
      menu:
        label: Seleziona le pagine da includere nella barra del menù (e nel footer)
        type: pages
        width: 1/2
      #
      social:
        label: Indica qui i social
        type: structure
        width: 1/2
        fields:
          url:
            label: Url
            type: url
            width: 1/2
          logo:
            label: Logo (formato .SVG)
            type: files
            max: 1
            width: 1/2

Solved, was a multi-language problem, because the old site was with 2 languages active, and the new K3 site was with just one. Setting the right languages everything is ok.

Solved!