1

Topic: Menu for Bootstrap4 (2 levels only)

Hi there,
I just wanted to share this menu for Bootstrap4, please note that works only for 2 levels.
Any improvements are more than welcome (maybe unlimited levels)

<nav class="navbar navbar-expand-md navbar-dark bg-dark sticky-top">
  <div class="container">
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
        <!--<span class="navbar-toggler-icon"></span>-->
        <i class="fa fa-bars fa-2x" aria-hidden="true"></i>
    </button>
    <a  class="navbar-toggler" href="tel:<?php echo PHONE; ?>"><i class="fa fa-phone fa-2x" aria-hidden="true"></i></a>
    <a  class="navbar-toggler" href="https://www.google.ca/maps/dir/Your+Location/<?php echo ADDRESS.'+'.CITY.'+'.PROVINCE.'+'.POSTALCODE; ?>" target="_blank" id="dd"><i class="fa fa-map-marker fa-2x" aria-hidden="true"></i></a>

    <div class="collapse navbar-collapse" id="navbarNavDropdown">
      <ul class="navbar-nav mr-auto">
        <li class="nav-item"><a class="nav-link" href="<?php echo URL_PUBLIC; ?>">Home</a></li>
        <?php foreach ($this->find('/')->children() as $menu): ?>
        <?php if (count($menu->children()) > 0) : ?>
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><?php echo $menu->title(); ?></a>
          <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
            <?php foreach ($this->find($menu->slug())->children() as $child): ?>
            <?php echo $child->link($child->title, ' class="dropdown-item"'); ?>
            <?php endforeach; ?>
          </div>
        </li>
      <?php else : ?>
        <li class="nav-item"><a class="nav-link" href="<?php echo URL_PUBLIC; ?><?php echo $menu->slug(); ?>"><?php echo $menu->title(); ?></a></li>
      <?php endif; ?>
      <?php endforeach; ?>
      </ul> 
    </div>
  </div>
</nav>

Thumbs up