更新:调整前端菜单栏输出
parent
2024c80bbf
commit
13cdf6be3b
|
@ -19,6 +19,7 @@ class Menu
|
||||||
$data = [
|
$data = [
|
||||||
'categoryId' => $categoryId,
|
'categoryId' => $categoryId,
|
||||||
'menus' => $menus,
|
'menus' => $menus,
|
||||||
|
'currentFirstId' => $currentFirstId,
|
||||||
];
|
];
|
||||||
return View::assign($data)->fetch('public/menu');
|
return View::assign($data)->fetch('public/menu');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,43 @@
|
||||||
|
{php}
|
||||||
|
function getMenus($menus, $level = 1, $currentFirstId, $categoryId) {
|
||||||
|
$menuHtml = '';
|
||||||
|
if (count($menus) > 0) {
|
||||||
|
$menuHtml .= '<ul class="menu-level-'.$level.'">';
|
||||||
|
foreach ($menus as $menu) {
|
||||||
|
$activeClass = '';
|
||||||
|
if ($currentFirstId == $menu['id']) {
|
||||||
|
$activeClass = ' menu-active';
|
||||||
|
} elseif ($categoryId == $menu['id']) {
|
||||||
|
$activeClass = ' menu-item-active';
|
||||||
|
}
|
||||||
|
$menuHtml .= '<li class="menu-item-level-'.$level.$activeClass.'" >';
|
||||||
|
$aHref = 'javascript:;';
|
||||||
|
if (!empty($menu['url'])) {
|
||||||
|
$aHref = $menu['url'];
|
||||||
|
} elseif ($menu['is_index']) {
|
||||||
|
$aHref = url('/');
|
||||||
|
} elseif (!empty($menu['template'])) {
|
||||||
|
$aHref = url('/'.$menu['template'].'/'.$menu['id']);
|
||||||
|
}
|
||||||
|
$menuHtml .= '<span><a href="'.$aHref.'" target="'.$menu['style'].'">'.$menu['title'].'</a></span>';
|
||||||
|
if (isset($menu['children']) && count($menu['children']) > 0) {
|
||||||
|
$menuHtml .= getMenus($menu['children'], $level + 1, $currentFirstId, $categoryId);
|
||||||
|
}
|
||||||
|
$menuHtml .= '</li>';
|
||||||
|
}
|
||||||
|
$menuHtml .= '</ul>';
|
||||||
|
}
|
||||||
|
return $menuHtml;
|
||||||
|
}
|
||||||
|
{/php}
|
||||||
|
|
||||||
<div class="head_box wf100">
|
<div class="head_box wf100">
|
||||||
<div class="between-center w90">
|
<div class="between-center w90">
|
||||||
<a href=""><img src="__IMG__/logo.png" class="logo" alt=""></a>
|
<a href=""><img src="__IMG__/logo.png" class="logo" alt=""></a>
|
||||||
<div class="fr between-center">
|
<div class="fr between-center">
|
||||||
<div class="head_menu">
|
<div class="head_menu">
|
||||||
<ul>
|
{:getMenus($menus, 1, $currentFirstId, $categoryId)}
|
||||||
{foreach $menus as $menu}
|
|
||||||
<li {if $categoryId == $menu['id']}class="active"{/if}>
|
|
||||||
<a href="{:getUri($menu)}">{$menu.title}</a>
|
|
||||||
</li>
|
|
||||||
{/foreach}
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
<a href="tel:18081028996" class="phone"><span>联系我们</span></a>
|
|
||||||
<div class="head_btn">
|
<div class="head_btn">
|
||||||
<i class="bar-top"></i>
|
<i class="bar-top"></i>
|
||||||
<i class="bar-cen"></i>
|
<i class="bar-cen"></i>
|
||||||
|
|
Loading…
Reference in New Issue