wellcms 2.0 页头调用导航和子菜单的方式,直接复制使用。
第一种下拉菜单:
<ul class="navbar-nav mr-auto"> <li class="nav-item home" fid="0" data-active="fid-0"> <a class="nav-link" href="<?php echo $conf['path'] ;?>"><i class="icon-home d-md-none"></i> <?php echo lang('index_page');?></a> </li> <!-- 遍历需要显示的导航 --> <?php if ($forum_nav = category_tree(GLOBALS('forum_nav'))) { foreach($forum_nav as $_forum) { ?> <!-- li 格式 重新定义或添加新 class --> <li class="nav-item <?php if ($_forum['son']){echo 'dropdown';}?>" fid="<?php echo $_forum['fid'];?>" data-active="fid-<?php echo $_forum['fid'];?>"> <!-- a标签格式 重新定义或添加新 class --> <a class="nav-link <?php if ($_forum['son']){echo 'dropdown-toggle';}?>" href="<?php echo $_forum['url'];?>" <?php if ($_forum['son']){echo 'id="Menu-'.$_forum['fid'].'" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"';}?> <?php if ($_forum['category'] == 3){echo 'target="_blank"';}?>> <i class="icon-circle-o d-md-none"></i> <?php echo $_forum['name'];?> </a> <!--子菜单--> <?php if (isset($_forum['sonlist'])){ ?> <div class="dropdown-menu" aria-labelledby="Menu-<?php echo $_forum['fid'];?>"> <?php foreach($_forum['sonlist'] as $_son) { ?> <!-- a标签格式 重新定义或添加新 class --> <a class="dropdown-item" href="<?php echo $_son['url'];?>" <?php if ($_son['category'] == 3){echo 'target="_blank"';}?>> <i class="icon-circle-o d-md-none"></i> <?php echo $_son['name'];?> </a> <?php } ?> </div> <?php }?> </li> <?php }} ?></ul> /* 关闭click.bs.dropdown.data-api事件,使头部顶级菜单可点击,如鼠标点击无法弹出,请 css 追加 .navbar-nav > li:hover .dropdown-menu {display: block;} span.dropdown:hover .dropdown-menu {display: block;} */
第二种:点击频道后进入频道页面后,显示的横向子导航。
(1)频道页面使用的代码:
<?php if ($forum_nav[$forum['fid']]['son']) { ?><div class="container"> <ul class="nav"> <?php $forum_nav = category_tree(GLOBALS('forum_nav')); foreach($forum_nav[$forum['fid']]['sonlist'] as $_forum) { ?> <li class="nav-item" fid="<?php echo $_forum['fid'];?>" data-active="fid-<?php echo $_forum['fid'];?>"> <a class="nav-link" href="<?php echo $_forum['url'];?>"> <?php echo $_forum['name'];?> </a> </li> <?php } ?> </ul></div><?php } ?>
(2)子栏目页面使用的代码:
<?php if ($forum['fup']) { ?><div class="container"> <ul class="nav"><!-- 如果没有设置导航显示 <?php $forum_nav = category_tree(GLOBALS('forum_nav')); foreach($forum_nav[$forum['fup']]['sonlist'] as $_forum) { ?> 替换成如下代码 <?php $_forumlist = category_tree(GLOBALS('forumlist')); foreach($_forumlist[$forum['fup']]['sonlist'] as $_forum) { ?> --> <?php $forum_nav = category_tree(GLOBALS('forum_nav')); foreach($forum_nav[$forum['fup']]['sonlist'] as $_forum) { ?> <li class="nav-item" fid="<?php echo $_forum['fid'];?>" data-active="fid-<?php echo $_forum['fid'];?>"> <a class="nav-link" href="<?php echo $_forum['url'];?>"> <?php echo $_forum['name'];?> </a> </li> <?php } ?> </ul></div><?php } ?>
希望以上内容对你有所帮助!如果还有其他问题,请随时提问。 各类知识收集 拥有多年CMS企业建站经验,对 iCMS, Fastadmin, ClassCMS, LeCMS, PbootCMS, PHPCMS, 易优CMS, YzmCMS, 讯睿CMS, 极致CMS, Wordpress, HkCMS, YznCMS, WellCMS, ThinkCMF, 等各类cms的相互转化,程序开发,网站制作,bug修复,程序杀毒,插件定制都可以提供最佳解决方案。
未经允许不得转载:Str Tom工作室 » Wellcms,二级导航调用