首頁  >  文章  >  CMS教程  >  如何用帝國標籤實現當前欄位高亮

如何用帝國標籤實現當前欄位高亮

藏色散人
藏色散人原創
2019-12-13 09:16:082346瀏覽

如何用帝國標籤實現當前欄位高亮

如何用帝國標籤實現目前欄位高亮?

用帝國自訂標籤實作目前欄位高亮

。一番測試下來,找到了自己覺得方便的方法, 特記錄在此。

1、因為要用到自訂標籤,所以首先要在\e\class\userfun.php 加入一個自訂函數, 即 

推薦學習《帝國cms教程

程式碼如下:

//取得顶级栏目ID函数 
function user_GetTopBclassid($classid){ 
global $class_r; 
$fr=explode('|',$class_r[$classid][featherclass]); 
$topbclassid=$fr[1]?$fr[1]:$classid;//取得第一级栏目id 
return $topbclassid; 
}

2、接下來用靈動標籤呼叫導航部分,用5d6652f3e23d11ca2c26c39f8faa1fc5動態取得當前欄id以及父親欄id。

程式碼如下:

<ul class="menu"> 
<li id="current"><a href="/">首页</a></li> 
<!--灵动标签开始--> 
[e:loop={&#39;select classid,classname,classpath,bclassid,bname from [!db.pre!]enewsclass where bclassid=0 order by classid&#39;,0,24,0}] 
<li id="current<?=$bqr[classid]?>"><a href="<?=$public_r[newsurl]?><?=$bqr[classpath]?>" title="<?=$bqr[bname]?>" target="_self" ><?=$bqr[classname]?></a></li> 
[/e:loop] 
<style type="text/css"><!--加入动态css样式--> 
<!-- 
#menu #current<?=user_GetTopBclassid($GLOBALS[navclassid])?> /*---动态获取当前栏目id -*/ 
{background:url(/images/2008a/bg_menu_on_left.gif) no-repeat; font-weight:bold;} 
#menu #current<?=user_GetTopBclassid($GLOBALS[navclassid])?> a,#menu #current<?=user_GetTopBclassid($GLOBALS[navclassid])?> a:hover{color:#000; background:url(/images/2008a/bg_menu_on_right.gif) no-repeat right;} 
--> 
</style> 
<!--灵动标签结束-->

3、在範本變數中製作變數, 如[!--temp.tab--] 在其中加入步驟2的程式碼, 就可以在首頁及列表頁呼叫啦, 

引用wc在論壇的一個回复5d6652f3e23d11ca2c26c39f8faa1fc5 

#當為首頁的時候當前欄位是為空即channle 

目前為一級欄位時,則為channle目前欄位id 

當有欄位為非一級欄目,則為channle一級父欄id 

#封面模板、清單模板、內容模板下都有效

以上是如何用帝國標籤實現當前欄位高亮的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn