Example #1
0
 public static function renderNav($nav, $currentUrl = null, $depth = 1)
 {
     $html = '';
     foreach ($nav as $loop) {
         $selected = isset($currentUrl) && \Rebond\Util\Nav::isActive($currentUrl, $loop['friendlyurl']) !== false && $loop['id'] != 1 ? ' class="active"' : '';
         if (isset($loop['children']) && count($loop['children']) > 0) {
             $html .= '<li class="has-dropdown"><a href="' . $loop['url'] . '">' . $loop['title'] . '</a>';
             $html .= '<ul class="dropdown sub-nav">';
             $html .= self::renderNav($loop['children'], $currentUrl, $depth + 1);
             $html .= '</ul>';
         } else {
             $html .= '<li' . $selected . '><a href="' . $loop['url'] . '">' . $loop['title'] . '</a></li>';
         }
     }
     return $html;
 }