Mixed menu I with a headline

Hi all

I was wondering if anyone has created a mixed menu, with a headline. So really it would be the ‘Multiple Independent Custom Menus’ with the ability to add custom url’s as demonstrated in the Mixed Menu I example.

I can create separate menu structures, but I’m thinking is there a way to have one with all of it included?

What I want to achieve is.

Headline 1
page 1
page 2
page 3

Headline 2
page 4
page 5
url title (url)
page 6

Can you share your code? I am not exactly sure what you want to archive.

I guess you already tried to implement some of these: Menus | Kirby CMS

I was looking at the Menu builders | Kirby CMS.

I wanted to have multiple independent custom menus (sample 2) with the posibility to add url’s to external sites - that is mentioned in sample 3. So basically those two put together.

As mentioned earlier, I can just build two different menu structures, one for multiple independent custom menus, and one for the mixed menu, and then give the mixed menu a title through the template. But I thought maybe there’s an easier way.

You could nest the structure, i.e. use a structure field inside the structure to add headlines.

I did try that, and that did work on the panel side, but I wasn’t sure how to display the nested structure on the template side.

Are there any guides for that?

You need two loops for a nested structure, one for the 1st level, then another one for the nested structure inside.

basically like this:

foreach ($page->mainStructure()->toStructure() as $item) {
  echo $item->headline();
  $nested = $item->nestedStructure()->toStructure();
  foreach ($nested as $subItem) {
    // access fields of $subitem
    echo $subItem->whatever();
  }
}

I will give this a go and let you know how I go. Thank you.