本文實例講述了DEDECMS列表頁調(diào)用當(dāng)前欄目父級欄目的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:
修改方法如下
首先找到如下代碼:
復(fù)制代碼代碼如下: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 ";
}
然后將下面代碼拷貝到其后面:
復(fù)制代碼代碼如下: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是調(diào)用當(dāng)前目錄對應(yīng)的頂級目錄'fatherlist' 是調(diào)用上一級目錄,當(dāng)前目錄對應(yīng)的頂級目錄標(biāo)記:
復(fù)制代碼代碼如下:{dede:channel type='topone'}[field:typename/]{/dede:channel}
這個方法絕對可以,如果想用鏈接的話,就要[field:typeurl].
更多信息請查看IT技術(shù)專欄