帝国CMS导航条调用栏目一二级,如果有二级栏目,则调用,否则只调用一级栏目代码分享给大家,加上这个判断导航条显示就非常完美,代码如下:
<div class="topnav">
<h2><a href="<?=$public_r['add_pcurl']?>/"><?=$public_r[sitename]?></a></h2>
<nav>
<ul id="starlist">
<li><a href="<?=$public_r['add_pcurl']?>/">网站首页</a></li>
[e:loop={"select classid,classname,classpath,classimg from [!db.pre!]enewsclass where bclassid='0' and showclass=0 order by myorder asc,classid asc",0,24,0}]
<?
$cr=$empire->fetch1("select classid from {$dbtbpre}enewsclass where bclassid = '".$bqr[classid]."' limit 1");
if ($cr[classid]){
?>
<!--判断是否有子栏目,如果有出现子栏目样式,如果没有出现一级栏目的样式-->
<li class="menu"><a href="<?=$public_r['add_pcurl']?>/<?=$bqr[classpath]?>/"><?=sub($bqr[classname],0,54,false)?></a>
<ul class="sub">
<?php
$newbook=$empire->query("select classid,classname,classpath from {$dbtbpre}enewsclass where bclassid = '".$bqr[classid]."' and showclass=0 order by myorder asc,classid asc");
while($r=$empire->fetch($newbook)) {
?>
<li><a href="<?=$public_r['add_pcurl']?>/<?=$r[classpath]?>/"><?=sub($r[classname],0,54,false)?></a></li>
<?php
}
?>
</ul>
<span></span>
</li>
<?}else{?>
<li><a href="<?=$public_r['add_pcurl']?>/<?=$bqr[classpath]?>/"><?=sub($bqr[classname],0,54,false)?></a></li>
<?}?>
[/e:loop]
</ul>
</nav>
<h2 id="mnavh"><span class="navicon"></span></h2>
</div>
以上代码是本站导航直接复制粘贴出来的,用到了灵动标签的调用,毫无保留!