Access nested foreach with toStructure()

In your example, $menu->id() already prints all the menu items, because that element is nested under id…

<?php foreach($page->menus()->toStructure() as $menu): ?>
  <?php echo $menu->headline() ?> <br>
  <?php echo $menu->subline() ?> <br>
  <?php echo $menu->id()->value() ?> <br>
    <?php foreach($menu->id() as $item) {
      echo $item->title() . '<br>';
      echo $item->description() . '<br>';
    } ?>
<?php endforeach ?>

A little dump() or var_dump() -ing of stuff helps a lot to debug these kinds of issues…, just saying :wink:

And as @philipp already pointed out, hope you are not planning to use the Panel with that sort of nested content.

1 Like