今天再发布一种实现帝国CMS当前栏目高亮的方法:
第一步:打开 /e/class/userfun.php 文件,在 ?> 内添加以下代码
1
|
function currentPage( $classid , $thisid ){ global $class_r ; $fr = explode ( '|' , $class_r [ $classid ][featherclass]); $topbclassid = $fr [1]? $fr [1]: $classid ; //取得第一级栏目id if ($topbclassid==$thisid) { echo "class='cur'"; } else { }} |
模板里使用以下代码调用:
1
|
<ul><li <?php if ( empty ( $GLOBALS [navclassid])){ echo "class='cur'" ;} ?>><a id= "nav-hover0" href= "[!---news.url--]" >首页</a></li><?php $i =0; $path = "" ;?>[e:loop={ 'select classid,classname,classpath,wburl from [!db.pre!]enewsclass where bclassid=0 order by classid' ,0,24,0}]<?php $i = $i +1; $path = $public_r [newsurl]. $bqr [classpath]; if (! empty ( $bqr [wburl])){ $path = $bqr [wburl]; }?><li <?=currentPage( $GLOBALS [navclassid], $bqr [classid])?>><a id= "nav-hover<?=$i?>" href= "<?=$path?>" title= "<?=$bqr[classname]?>" target= "_self" ><?= $bqr [classname]?></a></li>[/e:loop]</ul> |