Manual sorting of subpages errors and inconsistencies

I have been trying to create a page with a sortable list of subpages. Whenever I try to manually rearrange the posts, I am getting erratic results. Most (but not all) of the time I drag-and-drop a subpage in the list I get the error message “The page directory cannot be moved”. And most (but not all) of the time, the sorting changes but in a slightly different order than I dropped the items in.

I’ve noticed that the folders often get duplicate prefixes (e.g. 13, 14, 15, 15, 17) after I’ve re-sorted the subpages, too. The numbers tend to be duplicates around the post that was just moved, and this often happens more often if I drag things further down in the list. Sometimes the order of several items gets changed, and sometimes posts get moved to a place several spots from where they were before they were rearranged.

I’ve seen a number of other people have asked and been helped about something similar, but not of those solutions have worked for me yet. I’ve double checked that my folders all have unique index numbers, and I’ve haven’t turned on any sorting in the field.

Even when I rename all of the folders to ensure there are no duplicates index numbers, the next time I drag them into a different order, I still run into the same error message and the same disorganized index numbers.

Here’s my blueprint for that field in my Projects page:

I’m not sure what other info I can provide to help narrow down the problem. Thank you for any help you can give!

How many projects are in this folder?
What sort of content do the projects contain?
Is this happening locally or on your production server?

Thank you for the quick reply!

  • There are 40 projects in the folder, but I anticipate having more than 120.
  • This is for an artist’s portfolio site, so the projects contain titles, images (sometimes 20+), descriptions and other meta information. I can post the blueprint if that would be helpful.
  • This is happening locally. I’ll post this online shortly in case that could be useful, too.

My experience is that the issue you describe happens if you have a rather slow server but lots of data that needs to be moved around, i.e. lots of child pages that contain many huge images, and thus need quite a bit of memory.

What is your local dev environment?

It’s an M2 MacBook Pro with 32 GB of RAM. I don’t have a lot running, so there’s a lot of available memory for doing this. I’m created a staging server to test this online, and I’m experiencing the same issue.

Effectively this is just supposed to be renaming the folders in my ‘content’ folder, correct? Could I possibly handle renaming the folders with a homemade plugin using the “page.changeNum:before” hook and prevent Kirby from trying it?

I’ve been playing around with the idea of handling the re-sorting in a plugin using the “page.changeNum:before” hook, partially to see if I can find where the issue is coming from. All of my Project folders have unique indexes.

When I try to move the 1st project after the 2nd project, the hook is run on every project that needs to be re-sorted. I assume it should just set the first project to “2_’ and the second to “1_”, but it’s also trying to set the index for a bunch more folders, starting with folder “11_”:

2 → 1
1 → 2
11 → 9
12 → 11
13 → 12
14 → 13

38 → 37

There are 38 project folders. I don’t know what’s different about Project 11, but regardless, at the end of that sequence there would be no folders with the 38_ prefix.

I hope this helps narrow things down?

I think I figured out the issue. There were two folders with the same name (9_no-one and 32_no-one). This was definitely my fault as I copied that folder in from another place when I thought that project had been deleted.

I’m still not sure why it failed the way it did, especially since they had different index numbers, but at least it’s working now.

Thank you again for your help!

While these pages are different from a file system point of view, they are not unique pages from Kirby’s point of view. Duplicate slugs are not allowed and usually prevented by the Panel. But if you fiddle with the file system manually, you need to be extra careful.

This can also be an issue when using UUIDs (which is the default). If you manually copy stuff around, UUIDs might not be unique anymore.

That makes sense! Thanks again for all the help!