I’m migrating a site from K3 to K4; the previous developers have a projects section with over 200 project pages with the status of ‘unlisted’.
When I add a new page to this section it disappears to what seems like a random position - for example it might become 180th or something, and I am struggling to change the sort order so that the newest created pages show at the top. (I am talking about the panel view rather than frontend)
‘sortBy: title desc’ works, but I cannot get ‘sortBy: created desc’ to work.
title: Projects
tabs:
projects:
label: Projects
icon: page
columns:
main:
sections:
pages:
sortable: true
label: Projects
status: all
layout: cards
status: all
sortBy: title asc
Does this require there to be an actual date field in the pages that are to be sorted, or (does Kirby keep track of the created date somehow via the uuid perhaps?) Or am I doing something else wrong?
There is no such thing as a created date inherent to a page object. What you can do (but not for existing pages), is to create a created field which defaults to the current date and make this readonly.
Okay thanks. So I’m trying to work out how the existing pages are sorted as they don’t seem to currently be based on anything. The directories for each age in the content directory start with numbers such as this:
3_projects:
1-project-a
2-project-b
3-project-c
It was my understanding that numbers were only applied to content directories when listed but perhaps I am wrong. Could these numbers be something to do with the sorting in K3? The reason I ask is when I use the K3 version and add a new project page it appears at the top, but in the migrated version it just disappears way down into the list.
Ok yup so what I’m trying to work out is if sorting was applied, indicated by the dash, but theres no reference to sorting in the blueprint, what is that default sorting that has caused the dashes?
Okay @texnixe - after some digging I’ve discovered that Kirby 3 allowed for sorting of unlisted pages due to having the ‘edit’ view which K4 doesn’t have. So I now have all the content directories renamed and made public using the _ filename as follows:
3_projects:
1-project-a
2-project-b
3-project-c
However, when adding a new page in the panel the page still goes all the way to the bottom. In this instance there are over 100 subpages, so that means adding a page goes to the end of the pagination, even if taken out of draft. Do you know why this would be occuring and why a new page that’s added wouldn’t become first?
These folders still look the same as before, should be 1_project-a etc.
I have no idea what this mysterious edit view is supposed to be, I doubt K3 had a view that’s now missing in K4.
When you create a new page, it is created as a draft page. So if you have all statuses in the same section, it depends on what you order by and the order direction to determine if drafts are shown at the top or the bottom.
If you only have listed pages and they are numbered with the default number scheme, you can sort by number asc/desc.
sortBy: num desc
Note that sortBy (and flip) disable manual sorting.
Yes I didn’t change the example of the directory naming, but they do now use the underscores.
However after resetting server permissions and deleting the media folder drafts now appear at the top - I have no idea of the explanation for this but there we go.
FYI What I mean by the edit view is the option to view the pages in Kirby 3 - from what I can tell within this view you can still drag around pages to affect the sort order when unlisted, but in kirby 4 the pages need to be published in order to assign a manual sort order. (Screenshot below of the edit view option i’m referring to)