{php} function getMenus($menus, $level = 1, $currentFirstId, $categoryId) { $menuHtml = ''; $levelList = ['nav-first','nav-second','nav-third']; $navClass = $levelList[$level - 1] ?? ''; if (count($menus) > 0) { $menuHtml .= ''; if($level > 1) { $menuHtml .= '
'; } foreach ($menus as $menu) { $activeClass = ''; if ($currentFirstId == $menu['id'] || $categoryId == $menu['id'] || ($currentFirstId == 0 && $menu['is_index'])) { $activeClass = ' active'; } $aHref = getUri($menu); $aHref = empty($aHref) ? 'javascript:;' : $aHref; if($level == 1) { $menuHtml .= '
  • '; $menuHtml .= ''.$menu['title'].''; if (isset($menu['children']) && count($menu['children']) > 0) { $menuHtml .= getMenus($menu['children'], $level + 1, $currentFirstId, $categoryId); } $menuHtml .= '
  • '; } else { $menuHtml .= ''; $menuHtml .= ''.$menu['title'].''; if (isset($menu['children']) && count($menu['children']) > 0) { $menuHtml .= getMenus($menu['children'], $level + 1, $currentFirstId, $categoryId); } $menuHtml .= ''; } } if($level > 1) { $menuHtml .= '
    '; } } return $menuHtml; } {/php}