帝国cms同时调用一级、二级栏目并当前栏目高亮显示的方法,亲测可用!今天用帝国cms出现了需要同时调用1,2级栏目并给当前栏目高亮显示的需求,经过一番搜索,用以下代码即可实现(包含首页高亮)。
这里呢给大家提供两种方法,亲测都可用哦,
下面如果想不显示栏目的话直接栏目设置不显示栏目就行了,然后可以增加这么一个属性:
and showclass=0
改版前
[e:loop={"select classid,classname from {$dbtbpre}enewsclass where bclassid=0 order by myorder,classid asc",0,24,0}]
改版后
[e:loop={"select classid,classname from {$dbtbpre}enewsclass where bclassid=0 and showclass=0 order by myorder,classid asc",0,24,0}]
剩下爱的自己 研究哈,不细化了就。
方法一(增加排除不显示的栏目共能)
//自己区分一级跟二级吧,适用于下拉形式的那种导航站点哦。active喂高亮显示的样式
<div class="nav">
<ul class="1 clearfix">
<li class="active"><a href="/">首页</a></li>
<?php
$ealist = array(147,85,88,89);
?>
[e:loop={"select classid,classname from {$dbtbpre}enewsclass where bclassid=0 order by myorder,classid asc",0,24,0}]
<?php
$classurl = sys_ReturnBqClassname($bqr, 9);//取得栏目地址
$class = "";
if ($GLOBALS[navclassid]) {
$fcr = explode('|', $class_r[$GLOBALS[navclassid]][featherclass]);
$topbclassid = $fcr[1] ? $fcr[1] : $GLOBALS[navclassid];//取得当前栏目的一级栏目ID
if ($bqr[classid] == $topbclassid) {
$class = "active";
}
}
if (in_array($bqr['classid'], $ealist)) {
continue;
}
?>
<li><a id="<?= $class ?>" href="<?=$classurl?>"><?=$bqr['classname']?></a>
<ul style="display: none;">
<?php
$sqlstr = 'select * from ' . $dbtbpre . 'enewsclass where bclassid=' . $bqr['classid'] . ' order by myorder limit 0,20';
$query = $empire->query($sqlstr);
while ($row = $empire->fetch($query)) {
if (in_array($row['classid'], $ealist)) {
continue;
}
?>
<li>
<a href="<?= $public_r['newsurl'].ltrim($row['classpath']) ?>"><?= $row['classname'] ?></a>
</li>
<?php
}
?>
</ul>
</li>
[/e:loop]
<li class="active"><a href="https://m.cnjzb.com/">手机版</a></li>
</ul>
</div>
方法二(显示所有的栏目没排除功能,后台设置排除)
<nav>
<ul class="w-f">
<li class='h <?=$GLOBALS[navclassid]==0?"cur":"cur1"?>'> <a href="#" class="tit link">首页</a> </li>
[e:loop={"select classid,classname from {$dbtbpre}enewsclass where bclassid=0 order by myorder,classid asc",0,24,0}]
<?php
$classurl=sys_ReturnBqClassname($bqr,9);//取得栏目地址
$class="";
if($GLOBALS[navclassid])
{
$fcr=explode('|',$class_r[$GLOBALS[navclassid]][featherclass]);
$topbclassid=$fcr[1]?$fcr[1]:$GLOBALS[navclassid];//取得当前栏目的一级栏目ID
if($bqr[classid]==$topbclassid)
{
$class="cur";
}
}
?>
<li class="h link <?=$class?>"> <a href="<?=$classurl?>" class="tit link">
<?=$bqr[classname]?>
</a>
<div class="subnav f-cb dn">
<?php
$ecms_bq_sql2=sys_ReturnEcmsLoopBq("select classid,classname,classpath,classurl from [!db.pre!]enewsclass where bclassid='$bqr[classid]' order by myorder limit 10",20,24,0);
$bqno2=0;
while($bqr2=$empire->fetch($ecms_bq_sql2))
{
$bqsr2=sys_ReturnEcmsLoopStext($bqr2);
$bqno2++;
?>
<a href="<?=$classurl?>">
<?=$bqr2[classname]?>
</a>
<?php
}
?>
</div>
</li>
[/e:loop]
</ul>
</nav>