帝国ecms导航栏选中效果
文章描述:
帝国ecms导航菜单选中效果
方法一:
1、获取顶级栏目ID
<?php
if($class_r[$GLOBALS[navclassid]][bclassid]==0){
$classid=$GLOBALS['navclassid'];
$classname=$class_r[$classid][classname];
}else{
$classid=$class_r[$GLOBALS[navclassid]][bclassid];
$classname=$class_r[$classid][classname];
}
?>
2、判断顶级栏目ID
<li><a href="[!--news.url--]">首页</a></li>
<li class="<?if($classid==1){echo "cur";}?>"><a href="[!--news.url--]love">爱情</a></li>
<li class="<?if($classid==2){echo "cur";}?>"><a href="[!--news.url--]xingzuo">星座</a></li>
方法二:
<li><i class="fa fa-book"></i><a href="/" class="<?=$GLOBALS[navclassid]?"":"on"?>" > 首页</a></li>
<?php
$color=1;
$sql=$empire->query("select classid,classname,islast from {$dbtbpre}enewsclass where bclassid=0 and showclass=0 order by myorder,myorder asc");
while($s=$empire->fetch($sql)){
$tclass="";
$fr=explode('|',$class_r[$GLOBALS[navclassid]][featherclass]);
$topbclassid=$fr[1]?$fr[1]:$GLOBALS[navclassid];
if(($topbclassid==$s[classid])&&($ishome==0)){
$tclass='on';
}
$classurl=sys_ReturnBqClassname($s,9);
echo '<li><i class="fa fa-book"></i><a class="'.$tclass.'" href="'.$classurl.'">'.$s[classname].'</a>';
if(!$s[islast]){
$sql2=$empire->query("select classid,classname from {$dbtbpre}enewsclass where bclassid=$s[classid] and showclass=0 order by myorder,myorder asc");
$str="";
while($s2=$empire->fetch($sql2)){
$classurl2=sys_ReturnBqClassname($s2,9);
$str.='<li><a href="'.$classurl2.'">'.$s2[classname].'</a></li>';
}
//echo '<ul>'.$str.'</ul>';
echo $str;
}
echo '</li>';
}
?>
发布时间:2022/10/12
发表评论