原文来自:https://www.zixuephp.com

DEDECMS列表页调用当前栏目的父级栏目

修改方法如下首先找到如下代码:

  1. if($type=='top')
  2. {
  3. $sql="SELECTid,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
  4. From`detest_arctype`WHEREreid=0Andishidden<>1orderbysortrankasclimit0,$line";
  5. }
  6. elseif($type=='son')
  7. {
  8. if($typeid==0)return'';
  9. $sql="SELECTid,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
  10. From`detest_arctype`WHEREreid='$typeid'Andishidden<>1orderbysortrankasclimit0,$line";
  11. }//phpfensi.com
  12. elseif($type=='self')
  13. {
  14. if($reid==0)return'';
  15. $sql="SELECTid,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
  16. FROM`detest_arctype`WHEREreid='$reid'Andishidden<>1orderbysortrankasclimit0,$line";
  17. }

然后将下面代码拷贝到其后面:

  1. elseif($type=='topone')
  2. {
  3. if($reid==0)return'';
  4. $rowR=$dsql->GetOne("SELECT*FROM`detest_arctype`WHEREid='$typeid'");
  5. $topids=$rowR['topid'];
  6. $sql="SELECTid,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
  7. FROM`detest_arctype`WHEREreid='0'Andid='$topids'Andishidden<>1orderbysortrankasclimit0,$line";
  8. }
  9. elseif($type=='fatherlist')
  10. {
  11. $rowR=$dsql->GetOne("SELECT*FROM`detest_arctype`WHEREid='$typeid'");
  12. $reid=$rowR['reid'];
  13. $rowR=$dsql->GetOne("SELECT*FROM`detest_arctype`WHEREid='$reid'");
  14. $reid=$rowR['reid'];
  15. $sql="SELECTid,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
  16. FROM`detest_arctype`WHEREreid='$reid'Andishidden<>1orderbysortrankasclimit0,$line";
  17. }

说明topone是调用当前目录对应的顶级目录'fatherlist' 是调用上一级目录,当前目录对应的顶级目录标记:{dede:channel type='topone'}[field:typename/]{/dede:channel}

这个方法绝对可以,如果想用链接的话,就要[field:typeurl].