Hi,
is it possible to sort pages inside the panel by a date field?
I have a blueprint where I display all pages:
title: Neuigkeiten
icon: book
sections:
subpages:
label: Neuigkeiten
type: pages
layout: table
columns:
category: true
zeitpunkt: true
draft: Draft
listed: Published
template:
- neuigkeit
sortBy: zeitpunkt desc <-----------?
and the blueprint template “neuigkeit” which is used for created pages:
title: Neuigkeit
sections:
details:
type: fields
fields:
titel:
label: Titel
type: text
width: 1/3
required: true
zeitpunkt:
label: Zeitpunkt
type: date
display: DD-MM-YYYY
width: 1/3
required: true
Sorting them by my date field “zeitpunkt” in HTML works fine, but I want them to be sorted like this as well inside the panel and make them not sortable manually.
Thanks in advance!
That should actually work, what is the result?
i would have assumed that to work as well given there are values. apart from that imho there are no draft and listed props. and you could use either template with a string or templates with an array.
title: Neuigkeiten
icon: book
sections:
subpages:
label: Neuigkeiten
type: pages
layout: table
columns:
category: true
zeitpunkt: true
# draft: Draft
# listed: Published
templates:
- neuigkeit
sortBy: zeitpunkt desc # <-----------?
sometimes mixing tab and spaces for formatting yaml also causes issues. try moving the sortBy prop further up to make sure its not treated as a array element of template.
Thank you both for your help!
The result is, that it’s not sorting by date and I’m also able to sort them manually in the panel.
It also does not work when I move the sortBy up like this:
sections:
subpages:
label: Neuigkeiten
type: pages
layout: table
sortBy: zeitpunkt desc
columns:
category: true
zeitpunkt: true
template:
- neuigkeit
Do you have any other idea?
btw: “zeitpunkt” gets successfully pulled because in the table overview, I can see that it shows this field inside every column…
Could you post a screenshot of the result?
@pixelijn sure, here is a screenshot of the panel view. On the screenshot I hover on the last item so you can see that I have the drag & drop icon on the left. I can resort them which I actually don’t want.
That’s interesting, the sort handle should not be available when sortBy
is enabled.
@texnixe strange, here are my complete blueprints again, just in case:
title: Neuigkeiten
icon: book
sections:
subpages:
label: Neuigkeiten
type: pages
layout: table
columns:
category: true
zeitpunkt: true
draft: Draft
listed: Published
template:
- neuigkeit
title: Neuigkeit
sections:
details:
type: fields
fields:
infoSektion:
label: Informationen
type: headline
category:
label: Kategorie
type: select
options:
Rechtliches: Rechtliches
Baumaßnahmen: Baumaßnahmen
Baurechtschaffung: Baurechtschaffung
width: 1/3
required: true
titel:
label: Titel
type: text
width: 1/3
required: true
zeitpunkt:
label: Zeitpunkt
type: date
display: DD-MM-YYYY
width: 1/3
required: true
beschreibung:
label: Beschreibung
type: textarea
nodes: false
buttons: false
marks: false
help: "Bestenfalls maximal 300 Zeichen"
required: true
fotoSektion:
label: Bilder
type: headline
bilder:
label: Bilder
type: files
max: 10
layout: cards
query: page.images
help: Bitte komprimierte JPG's oder PNG's hochladen
I just tried to rename “Baumaßnahmen” to “Baumassnahmen” in my category field but it does not help either…
I’ll look into this tonight again.
1 Like
Ok, your last example code in neuigkeiten.yml for the section doesn’t have a sortBy
option, instead it has non-existing properties draft and listed. Your neuigkeiten.yml should look like this:
title: Neuigkeiten
icon: book
sections:
subpages:
label: Neuigkeiten
type: pages
layout: table
columns:
category: true
zeitpunkt: true
sortBy: zeitpunkt
template:
- neuigkeit
Thanks so much @texnixe, works perfectly.
Now, is there an option to reverse the sorting? Like “desc” or “asce”
See your own example above: Sorting in the panel possible? - #5 by tobias93, we were already there, don’t know why you went back in time…
@texnixe sorry, you‘re right.
Thanks again!