原文来自:https://www.zixuephp.com
DEDECMS列表页调用当前栏目的父级栏目
修改方法如下首先找到如下代码:
- if($type=='top')
- {
- $sql="SELECTid,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
- From`detest_arctype`WHEREreid=0Andishidden<>1orderbysortrankasclimit0,$line";
- }
- elseif($type=='son')
- {
- if($typeid==0)return'';
- $sql="SELECTid,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
- From`detest_arctype`WHEREreid='$typeid'Andishidden<>1orderbysortrankasclimit0,$line";
- }//phpfensi.com
- elseif($type=='self')
- {
- if($reid==0)return'';
- $sql="SELECTid,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
- FROM`detest_arctype`WHEREreid='$reid'Andishidden<>1orderbysortrankasclimit0,$line";
- }
然后将下面代码拷贝到其后面:
- elseif($type=='topone')
- {
- if($reid==0)return'';
- $rowR=$dsql->GetOne("SELECT*FROM`detest_arctype`WHEREid='$typeid'");
- $topids=$rowR['topid'];
- $sql="SELECTid,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
- FROM`detest_arctype`WHEREreid='0'Andid='$topids'Andishidden<>1orderbysortrankasclimit0,$line";
- }
- elseif($type=='fatherlist')
- {
- $rowR=$dsql->GetOne("SELECT*FROM`detest_arctype`WHEREid='$typeid'");
- $reid=$rowR['reid'];
- $rowR=$dsql->GetOne("SELECT*FROM`detest_arctype`WHEREid='$reid'");
- $reid=$rowR['reid'];
- $sql="SELECTid,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
- FROM`detest_arctype`WHEREreid='$reid'Andishidden<>1orderbysortrankasclimit0,$line";
- }
说明topone是调用当前目录对应的顶级目录'fatherlist' 是调用上一级目录,当前目录对应的顶级目录标记:{dede:channel type='topone'}[field:typename/]{/dede:channel}
这个方法绝对可以,如果想用链接的话,就要[field:typeurl].