Sort pages by datetime field in Panel

Hey there

I’m not sure if I am making a mistake or discovered a bug.

I have a Blog site with multiple blog article subpages. I would like to have the blog articles sorted by their “datetime” tag (in the panel). But the Kirby panel does not seem to name them accordingly, neither is the file structure.

I am using Kirby:
Toolkit version: 2.5.12
Kirby version: 2.5.12
Panel version: 2.5.12

here are the blueprints:

Blog:

title: Blog
icon: book

pages:
    template: blogarticle
    sort: datetime desc
    num:
      mode: datetime
      field: datetime
      format: d-m-y H
      display: d-m-y H

fields:
   title:
       label: Title
       type:  text

Blogarticle:

title: Blogarticle
icon: file

pages: default

fields:
  title:
    label: Title
    type:  text

tags:
    label: Tags (Fach)
    type:  tags

datetime:
    label: Date and Time
    type: datetime
    default: now
    date:
        format: DD-MM-YYYY
    time:
        format: 24

text:
    label: Text
    type: textarea

And the panel looks like this:

!

While the file structure still is numbered (1-data-mapping, 2-embodied-ideation…)

Am I missing something?
Greetings M.

Hey, welcome to the forum! Yes, by default it will sort by the folder number. You need to tweak your blueprint a little to get what you want, which looks like you have basically followed, but check your indentation. YAML is sensitive to indents.

The format you are sorting by doesn’t match the format of the field - im not not sure if that matters or not.

Hi,

thank you for the quick reply. I looked at the indentation, but that was not the mistake. The indentation was moved when I copied the text into the forum.

I found a solution though. By changing the num mode to date, it all worked out. The blog.yml file now looks like this:

title:       Blog
icon:        book

pages:
  template:  blogarticle
  sort:      datetime desc
  num:
    mode:    date
    field:   datetime
    # format:  dmy
    display: d.m.y – H:i

fields:
  title:
    label:   Title
    type:    text

It now makes sense to me that I had to use date instead of datetime. But I initially thought it would work with the type of datetime aswell.

Thanks for your help!

If you want to include the time in the numbering in the filesystem, you can do that using the format option. Just make sure not to use any dashes.