方法一:需要更改系统文件
第一步、将获取顶级栏目高亮的代码 复制到\e\class\userfun.php代码如下:
function currentPage($classid,$thisid){
global $class_r;
$fr=explode('|',$class_r[$classid][featherclass]);
$topbclassid=$fr[1]?$fr[1]:$classid;
if ($topbclassid==$thisid) {
echo "on";
}
else {
}
}
第二步、在模板中用下面代码调用导航栏
<ul>
<li <?php if(empty($GLOBALS[navclassid])){echo "class='on'";} ?>><a href="[!--news.url--]">首页</a></li>
<?php
$ecms_bq_sql=sys_ReturnEcmsLoopBq('select classid,classname,classpath from [!db.pre!]enewsclass where bclassid=0 and showclass=0 order by myorder limit 8',20,24,0);
$bqno=0;
while($bqr=$empire->fetch($ecms_bq_sql))
{
$bqsr=sys_ReturnEcmsLoopStext($bqr);
$bqno++;
?>
<!--一级栏目-->
<li><a href="<?=$public_r[newsurl]?><?=$bqr[classpath]?>" class="<?=currentPage($GLOBALS[navclassid],$bqr[classid])?>"><?=$bqr[classname]?></a>
<!--二级栏目-->
<ul>
<?php
$ecms_bq_sql2=sys_ReturnEcmsLoopBq("select classid,classname,classpath from [!db.pre!]enewsclass where bclassid='$bqr[classid]' order by myorder limit 5",20,24,0);
$bqno2=0;
while($bqr2=$empire->fetch($ecms_bq_sql2))
{
$bqsr2=sys_ReturnEcmsLoopStext($bqr2);
$bqno2++;
?>
<li><a href="/<?=$bqr2[classpath]?>" ><?=$bqr2[classname]?></a></li>
<?php
}
?>
</ul>
</li>
<?php
}
?>
</ul>
方法二:不需要更改系统文件
<ul>
< li <?php if(empty($GLOBALS[navclassid])){echo "class='item common active'";}else{echo "class='item common'";} ?>><a href="[!--news.url--]">首页</a></li>
[e:loop={"select classid,classname from {$dbtbpre}enewsclass where bclassid=0 and showclass=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";
}
}
?>
< li class="<?=$class?>" ><a href="<?=$classurl?>" ><?=$bqr[classname]?></a>
<ul>
<?php
$ecms_bq_sql2=sys_ReturnEcmsLoopBq("select classid,classname,classpath 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++;
?>
<li><a href="<?=$public_r[newsurl]?><?=$bqr2[classpath]?>" title="<?=$bqr2[classname]?>" ><?=$bqr2[classname]?></a></li>
<?php
}
?>
</ul>
< /li>
[/e:loop]
< /ul>