I am currently building my first Kirby theme. So far so good.
But what really bother me, is the fact that there is no good menu system implemented (or I didn’t found it yet). Let me explain.
I want to code something like this:
<?php echo menu('primary'); ?>
and on my footer something like
<?php echo menu('footer'); ?>
I don’t know what pages are going to be implemented. Perhaps they change. Perhaps my staff is doing crazy shit.
So it would be great to have a menu manger like Wordpress where I can simply build my menus. Storing that in a yaml-file shouldn’t be the problem and the CLI guys out there could simply edit it in an editor.
And beginners would be much happier I believe.
What do you think / have in mind / tipps do you have for me?
The starterkit does it using visible and invisible pages for example. Another way would be to introduce a checkbox field for top-level templates that can be checked if the page should appear in the menu. These are the two most common ways.
You could also create pages that work as menu builders, i.e. a page with a structure field to enter a menu title and select a page. That way, you can also sort menu items any way you want manually.
I’d go the same way @jenstornell suggested and either using his snippet field or the structure field. In addition, I would not create a separate page for this, but store the information in the site.txt – less pages for the panel user, and somehow better organized (it’s clearly a setting, not a page a visitor can go to).
You can even combine this with visible/invisible pages, and using invisible ones just as drafts.
If you only have one menu I think @jakobploens suggestion might be the best, put it in site.
In my case I had a top menu as well as child menus and in that case I used Subpage builder to automatically add a subpage called menu on parent template blueprints.
Then I use a route so the menu “pages” is not indexed but only used as placeholder in the panel.
There are very many ways to setup a menu system. It probably depends on the site and the users, how to work with it.
Yeah, that’s right. But submenus and stuff could then just be build with a simple checkbox… but yes, it depends on the overall site structure and complexity.
You mean that it work much like the visible pages? I used visible pages at first and then added a menu icon, menu title and a menu subtitle for it, fields on every subpage.
I personally did not like that approach because:
When adding stuff for the menu inside the child page I need to look at the front or on every child page to get a good overview of the final menu. Much back and forth.
I needed to go to Pages to sort them and make them visible. From time to time I forgot where to order them. If I can’t understand it, my client probably can’t do it eather.
It also did not look like the final menu. With my Snippetfield plugin the result looks almost like the final thing.
The big pitfall of my solution, except there is a menu page placeholder is:
When I delete a page, it is not reflected in the menu. I need to keep it updated manually. That could be solved with a hook, if needed.
So, I’ve tested both and for my current site I like the subpage version best. For another site, maybe I think different.
Could you write code that checks if pages in your menu still exist, and if not delete the menu entry? Then add a hook on panel.page.delete to trigger it.