更新:菜单栏-多级菜单的父菜单添加curcss类名

virtual
zwesy 2020-12-09 09:21:58 +08:00
parent 9db0a96685
commit 63f1189779
1 changed files with 10 additions and 4 deletions

View File

@ -17,17 +17,23 @@ function getMenus($menus, $level = 1, $currentFirstId, $categoryId) {
}
$aHref = getUri($menu);
$aHref = empty($aHref) ? 'javascript:;' : $aHref;
$spanClass = '';
$hasChild = false;
if (isset($menu['children']) && count($menu['children']) > 0) {
$hasChild = true;
$spanClass = 'class="cur"';
}
if($level == 1) {
$menuHtml .= '<li class="'.$activeClass.'" >';
$menuHtml .= '<span><a href="'.$aHref.'" target="'.$menu['style'].'">'.$menu['title'].'</a></span>';
if (isset($menu['children']) && count($menu['children']) > 0) {
$menuHtml .= '<span '.$spanClass.'><a href="'.$aHref.'" target="'.$menu['style'].'">'.$menu['title'].'</a></span>';
if ($hasChild) {
$menuHtml .= getMenus($menu['children'], $level + 1, $currentFirstId, $categoryId);
}
$menuHtml .= '</li>';
} else {
$menuHtml .= '<a href="'.$aHref.'" target="'.$menu['style'].'" class="'.$activeClass.'">';
$menuHtml .= '<span>'.$menu['title'].'</span>';
if (isset($menu['children']) && count($menu['children']) > 0) {
$menuHtml .= '<span '.$spanClass.'>'.$menu['title'].'</span>';
if ($hasChild) {
$menuHtml .= getMenus($menu['children'], $level + 1, $currentFirstId, $categoryId);
}
$menuHtml .= '</a>';