Kill the current menu system

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.

Personally, this rather looks like a bug in the page creation.

If I follow your instructions:

Then the resulted page ends up with this appendix and I just submitted the page creation form:

What it rather shoud do:

Tagging @bastianallgeier for glory and his opinion. :lollipop:

1 Like

There is a PR that - when added - will prevent pages starting with a number to resolve conflicts https://github.com/getkirby/panel/pull/476

Yeah, only that I closed my PR - it just didn’t feel like the right solution yet.

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 both PRs 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

I don’t understand. How could it be wrong?

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.

Yes, if we don’t get a config for it but that feels kind of hacky.

I decided to write a proper fix that just works. :heart: See https://github.com/getkirby/kirby/pull/261
Pinging @distantnative and @bastianallgeier for their opinion.

The PR works just as I described above.

1 Like

Which of the suggestions above did you follow?

The one as I described above:

When created, it looks like this:


the resulted folder has the name “4-30-days”

What happens when you punpublish/hide/invisibilize it?

Edit: Cause I like it, but have the feeling that we are running into problems there

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”.

Tagging @bastianallgeier because reasons :heart:

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.

No!

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”.