DEDECMS清單頁怎麼呼叫目前欄位父級欄位?
本文實例講述了DEDECMS清單頁面呼叫當前欄目父級欄目的方法。分享給大家供大家參考。具體實作方法如下:
修改方法如下
首先找到如下程式碼:
#程式碼如下:
if($type=='top') { $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath From `dede_arctype` WHERE reid=0 And ishidden<>1 order by sortrank asc limit 0, $line "; } else if($type=='son') { if($typeid==0) return ''; $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath From `dede_arctype` WHERE reid='$typeid' And ishidden<>1 order by sortrank asc limit 0, $line "; } else if($type=='self') { if($reid==0) return ''; $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `dede_arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line "; }
然後將下面程式碼拷貝到其後面:
程式碼如下:
else if($type=='topone') { if($reid==0) return ''; $rowR = $dsql->GetOne("SELECT * FROM `dede_arctype` WHERE id='$typeid' "); $topids = $rowR['topid']; $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `dede_arctype` WHERE reid='0' And id='$topids' And ishidden<>1 order by sortrank asc limit 0, $line "; } else if($type=='fatherlist') { $rowR = $dsql->GetOne("SELECT * FROM `dede_arctype` WHERE id='$typeid' "); $reid = $rowR['reid']; $rowR = $dsql->GetOne("SELECT * FROM `dede_arctype` WHERE id='$reid' "); $reid = $rowR['reid']; $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `dede_arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line "; }
說明topone是呼叫目前目錄對應的頂級目錄'fatherlist' 是呼叫上一層目錄,目前目錄對應的頂層目錄標記:
程式碼如下:
{dede:channel type='topone'}[field:typename/]{/dede:channel}
這個方法絕對可以,如果想用連結的話,就要[field:typeurl].
以上是DEDECMS清單頁怎麼呼叫目前欄位父級欄位的詳細內容。更多資訊請關注PHP中文網其他相關文章!