A new plugin is born: https://github.com/jenstornell/kirby-menu-editor
Use it like this:
snippet('menueditor');
or like this:
<?php foreach( $page->addresses()->toStructure() as $item ) : ?>
<?php $attributes = menuEditorAttributes($item); ?>
<li>
<a href="<?php echo page( $item->page() )->url(); ?>"<?php echo $attributes; ?>></a>
</li>
<?php endforeach;
More info about the plugin at https://github.com/jenstornell/kirby-menu-editor
5 Likes
Wow, that’s great! I wanted to build something like that for a client project with three separate menus some time ago.
For clients I think I’d need to change the page
field to a select field, they won’t ever understand this thing
Thanks a lot
Thanks!
You can modify the plugin… or you can override it like this:
fields:
my_menu:
label: My menu
extends: menueditor
fields:
page:
type: select
options:
page1: Page1
page2: Page2
The pitfall would be that you need to set the options manually.
… or this should work:
type: select
options: pages
Yes, you are right, it does. I forgot about that. Then the override syntax would be:
fields:
my_menu:
label: My menu
extends: menueditor
fields:
page:
type: select
options: pages
Version 0.2
I just released a new version of https://github.com/jenstornell/kirby-menu-editor
It fixes some major bugs and there are now three types of menus that can be added.
-
Default - Most common case menus
-
Minimal - Title and page only
-
Full - All that is in the default setup but also image and description.
More info in the repo.
I closed this repo today. I now think adding a structure field and then adding the code into a template/snippet could be done quite simple even without this plugins. Therefor this plugin did not have a purpose. It only had 4 likes on Github and was not one of the most liked plugins anyway.
Maybe close this post?