自定義導航欄目,不是標籤調用顯示的導航,php
就是手動寫死的欄目也能支持高亮。css
第一步:函數
打開 /e/class/userfun.php 加入如下函數代碼:spa
1code |
//取得頂級欄目ID函數 function user_GetTopBclassid($classid){ global $class_r; $fr=explode('|',$class_r[$classid][featherclass]); $topbclassid=$fr[1]?$fr[1]:$classid;//取得第一級欄目id return $topbclassid; } 教程 |
第二步:ci
使用這個代碼能夠調用出當前一級欄目ID資源
1io |
<?=user_GetTopBclassid( $GLOBALS [navclassid])?> table |
獲取到一級欄目ID就好辦了。
第三步:
在自定義導航欄目代碼時,能夠這樣寫:
1 |
<li id= "nav-1" >一流資源網</li><li id= "nav-2" >JS代碼</li><li id= "nav-3" >帝國CMS教程</li> |
這其中的這個數字就是一級欄目ID,把ID寫進去。
而後在模板頁面加上CSS代碼:
1 |
<style type= "text/css" >#nav-<?=user_GetTopBclassid($GLOBALS[navclassid])?> {color:#F00;}</sytle> |
原理就是,CSS代碼中自動獲取當前欄目一級欄目ID,就正好跟欄目裏對上了。
如打開的是 帝國CMS教程 欄目,CSS代碼就以下:
1 |
<style type= "text/css" >#nav-3 {color:#F00;}</sytle> |