I´m trying to create a menu with a sub sub menu. But it doesnt show me the sub sub menu on my menu - even I active this pages to “visible page”.
Main
sub 1
sub 1
sub 2
sub 1
sub 1
sub 2
sub 2
So I opened the menu.php file and found out: Theres is no script for this (?)
In the docs I found : https://getkirby.com/docs/cookbook/menus#sub-menu
But this simple add a sub menü somewehre on your site, where you´ve placed this script.
Is there any way to add the third level to my menu?
Didnt get it. How could this script help me out?
This script will just show me the first level. I want to integrate three levels in my menu.
Isnt this possible?
This is the result of the snippet when used on the StarterKit page structure (with an additional third level page added to “Project A”. As you can see, the script adds a level based class name to every li element to facilitate styling:
(Note that the repo @jimbobrjames linked to contains stuff for Kirby 1, so while the treemenu snippet can still be used, other stuff in that repo is no longer compatible with Kirby 2).
Edit:
If you don’t see all levels in your menu:
Make sure that all pages you want to show in the menu are visible or change the snippet accordingly.
Check your source code, if the levels are really not there or just not visible in the browser.
The key here is to save the menu as a snippet, otherwise it won’t work, because the snippet is called from within the snippet.
No it does not work. I even kicked off the whole CSS to avoid all possible “display: none”`s.
I placed the script in a snippet, in the very basic template and in a content site. All site are visible, of course.
But nothing is showing. Only the first deph :-/
I guess the script is buggy. I´ve now downloaded kirby, uploaded it on my webspace and placed the the script in a file ‘submenu.php’. Copy it into folder ‘snippets’ and placed <?php snippet('submenu') ?> in the header file.
After that I create three levels von content files.
And guess what? It still not working. I dont change anything in Kirby.
Does this script only works on “projects” templates?
I can assure you that the script does work, even in the latest Kirby version. The results I posted above - the html and the frontend menu - are from putting the snippet in a 2.5.8 StarterKit.
The problem with your snippet is that you called it submenu.php instead of treemenu.php but failed to rename the snippet call within the submenu snippet, which is still called treemenu. Since this snippet now does not exist, the recursive pattern can’t possibly work.
Either rename your snippet to treemenu.php or change the snippet call within submenu.php to snippet('submenu').