Possible to flip order of related pages in the picker?

I’ve got an events calendar with dates. A date can have multiple related pages. (It’s a website for a theatre director’s shows … Some nights, two shows get shown … the related pages are the shows.)

I was wondering if I can flip the order of the related pages in the picker … So that I have the most recent shows up top (they are the most likely ones to be picked). The one you see at the top (Woyzeck) is the oldest show. The pages have standard Kirby sorting … 1_Woyzeck is the folder of the oldest show.

This is the way it looks in the panel:

And this is the relevant part from the blueprint:

    sections:
      werke:
        type: fields
        fields:
          related:
            translate: false
            label: Gezeigte Werke
            type: pages
            query: site.find('werkliste')
            info: "({{ page.jahr }})"
            empty: "Keine Werke ausgewählt"
            link: false

If you sort them within your query by whatever you want to sort by, it should work.

Oh, I didn’t know I could sort in the query … I haven’t found an example in the docs.

I went here for reference:

(https://getkirby.com/docs/reference/panel/fields/pages#query-pages)

… but didn’t find anything about sorting…

The actually selected ones will appear in the order in which they were selected though. Just adding this here in case…

Yes, and that’s great! I only meant the sorting inside the picker… is there any way to modify that sorting?

You can read the following reference article to get a better understanding of sorting in the Blueprint:

That’s a section though, a pages field has different options, so you cannot apply this to a pages field!

Then this should be the right solution.
I have tried it and the current page is listed at the top of the dialog box.

Right, this is what I already suggested.

If I modify my query that currently looks like this

query: site.find('werkliste')

to that

query: site.find('werkliste').sortBy('jahr', 'desc')

I get the following error in the panel:

… thoughts?

this being the respective blueprint:

title: Werk

columns:
  - width: 1/2
    sections:
      textinformationen:
        type: fields
        fields:
          genre:
            help: z. B. Theater/Live-Film 
            type: text
            width: 1/2
            icon: tag
          ort:
            help: z. B. Theater Basel
            type: text
            width: 1/2
            icon: home
            placeholder: optional
          jahr:
            label: Jahr(e)
            help: z. B. 2018/2019
            type: text
            translate: false
            width: 1/2
            icon: calendar
            maxlength: 9
          aktualitaet:
            label: Aktualität
            type: checkboxes
            translate: false
            width: 1/2
            default: aktuell
            options:
              aktuell: aktuell
            help: Wird das Werk noch gezeigt?
          beschreibung:
            type: writer
            marks:
              - link
              - bold
              - italic
            nodes: false
          credits_personen:
            type: structure
            label: Credits (Personen)
            fields:
              rolle:
                label: Rolle(n)
                type: text
              name:
                label: Name(n)
                type: text
          credits_institutionen:
            type: writer
            marks:
              - link
              - bold
              - italic
            nodes: false
            label: Credits (Institutionen)
            icon: home
            help: "z. B. Mit Unterstützung durch den Fachausschuss Tanz & Theater der Kantone Basel-Stadt und Basel-Landschaft."
          kritiken:
            type: blocks
            fieldsets:
              - quote
            help: "Tipp: Sollte es für dieses Werk in der aktuell ausgewählten Sprache keine Kritiken geben, lösche bitte alle leeren Blöcke, damit auf der Website kein leerer dunkler Kasten angezeigt wird … eigentlich ist es so gebaut, dass das nicht passiert, aber sicher ist sicher 😉"
  - width: 1/2
    sections:
      bilder:
        help: "<p>Tipp: Das erste Bild in dieser Liste wird als großformatiges Bild auf der Seite des Werkes angezeigt. Bitte wähle hierfür ein Querformat, idealerweise 16/9.</p><p>Vermeide bitte Kommata in den Namen der Bilddateien, da diese zu Fehlern in der Funktionalität des CMS führen können.</p><p>Du kannst pro Sprache eine eigene Sortierung wählen.</p>"
        type: files
        template: bild
        info: "{{ file.dimensions }}"
        layout: cards
        size: small
        limit: 100
        image:
          ratio: 1/1
      filmlinks:
        type: fields
        fields:
          filme:
            label: Videos
            help: "Tipp: YouTube- und Vimeo-Links sind möglich.<br><br>Sollte es für dieses Werk in der aktuell ausgewählten Sprache keine Videos geben, lösche bitte alle leeren Blöcke, damit auf der Website kein Weißraum angezeigt wird."
            type: blocks
            fieldsets:
              - video
      zusatzinformationen:
        type: fields
        fields:
          line:
            type: line
          silbentrennung:
            help: "<p>z. B. Martin Luther Propaganda&amp;shy;symposium</p><p>Tipp: Falls, speziell in deutschsprachigen Titeln, Wörter zu lang sind, können die Silben dieser Wörter per HTML-Tag <em>&amp;shy;</em> getrennt werden.</p>"
            type: text
            icon: code

So unfortunately, the solution you suggested doesn’t work…

Never mind, I figured it out! I was because I needed to show the CHILDREN of “Werkliste”, not “Werkliste” itself … it threw an error because the parent of the pieces doesn’t have a year field … only it’s children:

site.find('werkliste').children.sortBy('jahr', 'desc')

Thank you so much for your support. Y’all rock :slight_smile:

But: “flip” doesn’t seem to be available…

asc or desc changes the order.

You know what? I did it.

site.find('werkliste').children.listed.flip

WORKS!

It only works though when all query results are listed objects. So “listed” was missing in order for it to work :slight_smile:

This is what it looks like now (so cool):

2 Likes

:+1: Great that you have found a solution.
And that you were able to gather insights.

1 Like

@GB_DESIGN & @texnixe thank you so much for pointing me in the right direction … I really appreciate it :slight_smile:

1 Like