Submenu not visible

Hi Forum!

I am currently working on a navigation with submenus. Everything is going well now,
except that the link which opens the subnavigation is not visible. I checked the styles and JS, which is not the issue (afaik), but the visibility of the items in the navigation.

     $menuPages = $site->children()->not('datenschutz', 'impressum');  ?>
 
 <?php foreach ($menuPages as $item) :?>
     <a href="<?= $item->url() ?>"><?= $item->menu() ?> </a>
 <?php endforeach  ; ?> 

This works fine with my navigation, but is missing two items. On click these reveal the submenu, but the navigation item to “click” on is not visible. I have checked the forum and the documentation with “isNotEmpty” or “isOpen” but do not really understand it. Not being lazy to read or learn :wink:

Thank so much in advance!

Hm, that looks a bit incomplete, where is the subnavigation? What is $item->menu()?

Thank you for your reply. I have been following the video tutorial, but unfortunately the $item->menu() was wrong.

I have a list of links i.E.

     <a  href="#">Link One</a>
        <div id="submenu_one">
           <a href="#">Link Two</a>
           <a href="#">Link Three</a>
           <a href="#">Link Four</a>
        </div><a  href="#">Link Five</a>
     <a  href="#">Link Six</a>
        <div id="submenu_two">
           <a href="#">Link Seven</a>
           <a href="#">Link Eight</a>
    <a  href="#">Link Nine</a>       
    <a  href="#">Link Ten</a>
    <a  href="#">Link Eleven</a>

I have built the navigation with html and wanted to convert it in Kirby. Link one and Link Six are folders in the Content Folder which contain more pages. How can I loop through these items to show the Menuitems, except the ones from the submenu. These will be opened onClick by JS.

Thank you so much in advance!

Sometimes you can look for errors 4 1/2 hours and simple have to remove all your code and start again. Links are visible now and JS only has to work.

1 Like