dede 子欄目獲取上級(jí)、頂級(jí)欄目的名字和鏈接
時(shí)間: 2019-05-13 11:27
閱讀: 次
作者:素材無(wú)憂網(wǎng)
在DEDE根目錄/include/taglib/下找到channel.lib.php文件找到
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 ";
}
然后,在此段代碼下加入如下代碼,為{dede:channel}添加父級(jí)(parent)欄目屬性
else if($type=='parent')
{
$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
From `dede_arctype` where id='$reid' AND ishidden<>1 order by sortrank asc limit 0, $line ";
}
然后用下面的就行了
<!--調(diào)用當(dāng)前欄目的頂級(jí)欄目名稱-->
{dede:channel type='parent' }
[field:typename/]
{/dede:channel}
dede 子欄目獲取上級(jí)、頂級(jí)欄目的名字和鏈接
上面的方法當(dāng) 當(dāng)前欄目就是頂級(jí)欄目時(shí)候會(huì)失效,所以需要用到下面的方法【非無(wú)限子欄目】
{dede:field.typeid runphp='yes'}$ID = @me; $sql = "SELECT * FROM `dede_arctype` WHERE id=$ID";$query = mysql_query($sql);$row=mysql_fetch_array($query); $relID = "$row[reid]"; if($relID == 0) {@me = $row[typename];}else{$sql = "SELECT `typename` FROM `dede_arctype` WHERE id=$relID";$query = mysql_query($sql);$row=mysql_fetch_array($query); @me = $row[typename];}{/dede:field.typeid}
下面是頂級(jí)欄目的ID【非無(wú)限子欄目】
{dede:field.typeid runphp='yes'}$ID = @me; $sql = "SELECT * FROM `dede_arctype` WHERE id=$ID";$query = mysql_query($sql);$row=mysql_fetch_array($query); $relID = "$row[reid]"; if($relID == 0) {@me = $row[id];}else{$sql = "SELECT `id` FROM `dede_arctype` WHERE id=$relID";$query = mysql_query($sql);$row=mysql_fetch_array($query); @me = $row[id];}{/dede:field.typeid}
下面是無(wú)限子欄目獲取頂級(jí)欄目資料的方法,不過(guò)下面的實(shí)例是獲取頂級(jí)欄目下,的第二個(gè)欄目的方法,不過(guò)要獲取頂級(jí)欄目的話,更簡(jiǎn)單,所做修改即可。
{dede:field.typeid runphp='yes'}
$ID = @me;
$sql = "SELECT * FROM `dede_arctype` WHERE id=$ID";
$query = mysql_query($sql);
$row=mysql_fetch_array($query);
$relID = $row[reid];
$jishu;
while($relID != 0){
$jishu = $row[id];
$sql = "SELECT * FROM `dede_arctype` WHERE id=$relID";
$query = mysql_query($sql);
$row=mysql_fetch_array($query);
$relID = $row[reid];
}
$sql = "SELECT * FROM `dede_arctype` WHERE id=$jishu";
$query = mysql_query($sql);
$row=mysql_fetch_array($query);
@me = $row[arcpic];
{/dede:field.typeid}
版權(quán)聲明:
本站資源均來(lái)自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!
轉(zhuǎn)載請(qǐng)注明:
dede 子欄目獲取上級(jí)、頂級(jí)欄目的名字和鏈接
標(biāo)簽: