79 lines
3.0 KiB
HTML
79 lines
3.0 KiB
HTML
{php}
|
|
//dump($menus);
|
|
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 .= '<div class="'.$navClass.'" >';
|
|
}
|
|
|
|
|
|
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;
|
|
$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 '.$spanClass.'><a href="'.$aHref.'" target="'.$menu['style'].'">'.$menu['title'].'</a></span>';
|
|
if ($hasChild) {
|
|
$menuHtml .= getMenus($menu['children'], $level + 1, $currentFirstId, $categoryId);
|
|
}
|
|
$menuHtml .= '</li>';
|
|
} else {
|
|
if($menu['template_list']=='products'){
|
|
$menuHtml .= '<a href="'.$aHref.'#product" target="'.$menu['style'].'" class="'.$activeClass.'">';
|
|
}else if($menu['template_list']=='news'){
|
|
$menuHtml .= '<a href="'.$aHref.'#news" target="'.$menu['style'].'" class="'.$activeClass.'">';
|
|
}else
|
|
{
|
|
$menuHtml .= '<a href="'.$aHref.'" target="'.$menu['style'].'" class="'.$activeClass.'">';
|
|
}
|
|
$menuHtml .= '<span '.$spanClass.'>'.$menu['title'].'</span>';
|
|
if ($hasChild) {
|
|
$menuHtml .= getMenus($menu['children'], $level + 1, $currentFirstId, $categoryId);
|
|
}
|
|
$menuHtml .= '</a>';
|
|
}
|
|
}
|
|
if($level > 1) {
|
|
$menuHtml .= '</div>';
|
|
}
|
|
}
|
|
return $menuHtml;
|
|
}
|
|
{/php}
|
|
|
|
<div class="head-box w-100">
|
|
<div class="w-1500">
|
|
<div class="center-block w-100 between-center">
|
|
<div class="logo center-center">
|
|
<a href="{:url('/')}"><img src="__IMG__/logo.png"></a>
|
|
</div>
|
|
<div class="nav">
|
|
<ul>
|
|
{:getMenus($menus, 1, $currentFirstId, $categoryId)}
|
|
</ul>
|
|
</div>
|
|
<!-- <div class="language">
|
|
<a href="" class="active">中文</a> / <a href="">English</a>
|
|
</div> -->
|
|
<div class="nav_btn">
|
|
<i class="bar-top"></i>
|
|
<i class="bar-cen"></i>
|
|
<i class="bar-bom"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div> |