I know the topic title is quite strong, but I just want to wake you up for a discussion.
The menu is depending on first part in the slug
Even from Kirby 1 I did not like the menu system. Itâs because itâs driven by the first part of the slug, if itâs a number or not.
Why is this a problem?
I have a page about what can happen in 30 days.
In the panel I add a new page with the titleâŚ
30 days
âŚthen it will generate the slugâŚ
30-days
Fine, thatâs just what I want. Then when I visit the page I come toâŚ
days
Thatâs because the first number in the slug is not used as slug, but as a menu sorting number. It think that 30 is my menu order number. But itâs not.
Positive about the current menu system
Your folders will be sorted like your menu.
Negative about the current menu system
When using a menu I got numbers in my folder names. That can be confusing, because my folders does not reflect my page names anymore.
When I create pages starting with a number, it does not work, like â30-daysâ.
What I want from you
Solutions to the problems, as well as workarounds
Do you like the current menu system? If yes / no, why?
Suggestions how you would like it to work.
My suggestion
Iâm not so sure but I donât like the sorting number being in the slug. Move it from the slug to⌠I donât know.
Oh ok, itâs nevertheless an issue that should be resolved somehow. Maybe we should state in the docs that titles that start with a number are not possible or you somehow have to work around the issue by escaping such titles with a backslash and then replace in the template.
Iâm somehow really irritated why bothPRs were closed by @distantnative after creation.
What is the problem to figure out the latest sorting number there is and to prepend it to the page slug when creating instead of showing an error to a probably often used case?
As I said, simply because I decided that I wasnât convinced by my suggested solution anymore. Not saying that it doesnât need to be solved. Just not really sure yet what would be the right way. Maybe we can find one together.
I donât like having the menu number in the slug at all, but if we must here is a suggestion for itâŚ
1_30-days
2_30-days
This would work simply because underscore are allowed in folder names but they disallowed by Kirby as slug names. Kirby can add them for menu sorting, but we canât add them for slugs.
If slug contains an underscore, use the number before as sorting number, else use the slug as normal.
I still donât like the messing with the slugs, just to be clear on that.
Iâm not sure there is an easy fix, as long as the separator between the ordering number and the title is the same character as the space replacement in the slug.
Using another character would mitigate the issue (like an underscore: 30_30-days) by making it less likely, but it could still happen. Oh and it would break every existing site.
Edit: what about avoiding the first dash if the title starts with a number, when the slug is generated in the Panel?
â30 daysâ -> 30days instead of 30-days
if( has_underscore('30_30-days') ) {
$order = explode('_', '30_30-days');
echo $order[0];
// Should result in the first number (order) that is 30
echo $order[1];
// Should result in the slug that is 30-days
}
The code above is not complete. The function has_underscore does not exist here.
What I meant is that in this case when people update their existing site, theyâd have to change all their contentâs filenames from 1-my-title to 1_my-title otherwise the site wouldnât work anymore.
Fair point, since the act of hiding a page also includes getting rid of numbers, the â30â gets lost. The current mechanism of detecting hidden pages only relies on having no numbers in the folder name, which makes this problem impossible to solve without additional mechanics changes.
My suggestion would be:
Letâs introduce another way to hide pages. Lets just prepend _ at the slug, if the slug starts with a number. So all folders starting with _ would be hidden as well as the ones without numbers.
In short: âhomeâ is hidden, â_30-daysâ is hidden, â4-30-daysâ is visible. When you hide â4-30-daysâ in the panel, it automatically becomes â_30-daysâ.
I like @ciliceâs solution a lot. It feels right for Kirby â you could use this technique intuitively without the panel. I canât think of any new bugs this might spawn. It seems clean.
A new page that is not sorted is a hidden (invisible) one, right? That means ALL my pages will suddenly start with an underscore. I will probably never use the menu (page sorting), so it would probably be the most ugly change in the history of Kirby.
I was thinking that the underscore hidden pages will only be there if you hide a page that had numbers in it. If you hide â2-projectsâ, itâll still become âprojectsâ. Only if you hide â4-30-daysâ, itâll become â_30-daysâ.