Hi! Is it possible to define a custom number for sorting subpages via field?
Example: Theres a required field “ID” on the subpage, lets say “12345”. When saving or updating page, the number should be set as the folders sorting number for visible pages. Default numbering should be ignored.
Folder naming:
12345-subpage-a
56789-subpage-b
etc.
Is there any way to realise that?
Yes, that could be achieved via a panel.page.update
hook:
https://getkirby.com/docs/developer-guide/advanced/hooks
You would have to work around a lot of the “core principles” of Kirby panel, so you’ld have to take some of the possible “actions” into consideration and act properly on them:
- panel.page.create and panel.page.update for when you update the content (ID could be updated)
- panel.page.move is for when you make the page visible (by default Kirby reorders all sibling pages according to the new position you want this page to be - but you want it your way so you’ld have to code that)
- panel.page.hide is for when you hide the page (same as previous)
- panel.page.sort is for when an editor decides to reorder the pages (override default action on the folder and implement yours.
- …
@bvdputte is right.
Also, you would have to disable the status toggle and manual sorting in the Panel and do everything via the different hooks.