腾讯云优惠券

呆错文章管理系统导航栏调用实例

人气:57 更新:2022-12-18

navs.png

调用说明

  • 导航菜单调用主要通过助手函数 DcTermNavbar 来调用,相关参数请查询呆错框架助手函数
  • {volist name="navbars" id="navbar" offset="0" length="60"} 这里的60控制导航菜单数量
  • cmsNavActive 助手函数为菜单高亮处理函数
<nav class="navbar navbar-expand-md navbar-dark bg-purple mb-3">
<div class="container">
  <a class="navbar-brand d-md-none" href="{$path_root}">{:config('common.site_name')}</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#nav">
    <span class="navbar-toggler-icon"></span>
  </button>
  {if $user['user_id']}
    {assign name="navbars" value=":DcTermNavbar(['module'=>['in','common,user,cms'],'controll'=>['in','category,tag,navs'],'action'=>'index','type'=>'navbar','status'=>['in','normal,private']])" /}
  {else/}
    {assign name="navbars" value=":DcTermNavbar(['module'=>['in','common,user,cms'],'controll'=>['in','category,tag,navs'],'action'=>'index','type'=>'navbar','status'=>['in','normal,public']])" /}
  {/if}
  <div class="collapse navbar-collapse" id="nav">
    <hr class="w-100 mb-0 d-md-none">
    <ul class="navbar-nav w-100 d-flex flex-row flex-wrap">
    {volist name="navbars" id="navbar" offset="0" length="60"}
      {if $navbar['_child']}
        <li class="position-relative dropdown nav-item nav-mx {:cmsNavActive($module.$controll.$action, $term_id, $navbar['navs_active'], $navbar['navs_id'])}" id="term-{$navbar.navs_id}">
          <a class="nav-link dropdown-toggle" href="javascript:;" data-toggle="dropdown">{$navbar.navs_name|DcSubstr=0,6,false}</a>
          <div class="dropdown-menu">
            {volist name="navbar._child" id="navSon"}
            <a class="dropdown-item {:cmsNavActive($module.$controll.$action, $term_id, $navSon['navs_active'], $navSon['navs_id'])}" href="{$navSon.navs_link}" target="{$navSon.navs_target}">{$navSon.navs_name|DcSubstr=0,6,false}</a>
            {/volist}
          </div>
        </li>
      {else/}
        <li class="nav-item nav-mx {:cmsNavActive($module.$controll.$action, $term_id, $navbar['navs_active'], $navbar['navs_id'])}" id="term-{$navbar.navs_id}">
          <a class="nav-link" href="{$navbar.navs_link}" target="{$navbar.navs_target}">{$navbar.navs_name|DcSubstr=0,6,false}</a>
        </li>
      {/if}
    {/volist}
    </ul>
  </div>
</div>
</nav>