Problem sorting structure fields in panel

Hello everyone and a little bit late Merry Christmas!

So, I’m having some trouble sorting my structure entries in the panel.
According to the guide I should be able to sort asc or desc using one field, but it doesn’t seem to work for me.

Here’s my blueprint:

title: Lista degli eventi

icon: calendar

preset: pages

pages: event
files: false

options:
  delete: false
  status: false
  url: false
  title: false
  duplicate: false

fields:
          
  description:
    label: Testo introduttivo
    type: markdown
    size: small

  events:
    label: Prossimi eventi
    type: structure
    columns:
      dateBegins:
        width: 1/8
      dateEnds:
        width: 1/8
      eventName:
        width: 2/8
      eventDescription:
        width: 4/8

    # sortBy: dateBegins asc

    fields:
      eventName:
        label: Nome dell'evento
        type: text

      dateBegins:
        label: Data di inizio
        type: date
        default: today
        width: 1/2
      dateEnds:
        label: Data di fine
        type: date
        width: 1/2
        help: Se il campo viene lasciato vuoto l'evento ha la durata di un solo giorno

      dates:
        label: Date aggiuntive
        type: structure
        fields:
          dateBegins:
            label: Data di inizio
            type: date
            default: today
            width: 1/2
          dateEnds:
            label: Data di fine
            type: date
            width: 1/2
            help: Se il campo viene lasciato vuoto l'evento ha la durata di un solo giorno

      eventDescription:
        label: Descrizione dell'evento
        type: markdown
        size: small
        required: true
      eventSubscription:
        label: Informazione sulle iscrizioni
        type: markdown
        size: small
      eventNotes:
        label: Note aggiuntive
        type: markdown
        size: small

If I try to sort by dateBegins (but also by another field) I get the error t.items is undefined.

Any idea on what could be the problem? I can’t figure it out and I would really like to sort the entries!

Thanks a lot and have a nice evening!
Sara

I can’t reproduce the error. What Kirby version are you using?

However, sorting only works for me when the field name to sort by is all lowercase

sortBy: datebegins asc

Hi Sonja,
I’m using Kirby 3.3.0.

I’m used to using camel case but of course I can change.
Unfortunately I tried the lowercase instead but it didn’t work.

This is not the first time I have this problem, I don’t understand what I’m doing wrong. :confused:

Sonja I tried with a test blueprint and I manage to make it work.
I have to find which is the problem in the blueprint I’m actually using but thanks a lot for your tip!

Yes, I used camelCase for the fieldname itself as well, but for the fieldname in the sortBy: attribute I had to make it all lowercase, strangely. Maybe that’s a bug.

Anyway I don’t even know what I “touched” but it works just fine now.
I think that the problem is actually that, camelCase or not, the field names are store in the txt file in lowercase.

Thanks again, you’re always kind and make me find the error. :slight_smile:

1 Like