智慧建站平台,千套网站模板,免费随心选!

您现在的位置: 首页>>网站教程

DedeCms怎么获取任意栏目N级列表链接树形菜单

来源: 发布时间:2019-12-14热度:1501 ℃
dedecms怎么获取任意栏目n级列表链接树形菜单?DedeCms获取任意栏目N级列表链接树形菜单,小编提示,下边的修改方法,适用于DedeCMS默认的表前缀,如果你安装的时候修改了,请注意修改。推荐···

DedeCms怎么获取任意栏目N级列表链接树形菜单

dedecms怎么获取任意栏目n级列表链接树形菜单?

DedeCms获取任意栏目N级列表链接树形菜单,小编提示,下边的修改方法,适用于DedeCMS默认的表前缀,如果你安装的时候修改了,请注意修改。

推荐学习:织梦cms

在\include\channelunit.func.php文件底部添加如下代码:

/*树形栏目补充,获取二级,san级,四级栏目列表/ 
  
function getProductTree($typeid)
  
{
  
$linkList = "";
  
$dsql = new DedeSql(false);
  
$dsql->SetQuery("select ID,typedir,typename,isdefault from dede_arctype where reID = '$typeid' order by sortrank");
  
$dsql->Execute();
  
while($row=$dsql->GetObject())
  
{
  
   $typelink = GetTypeUrl($row->id,MfTypedir($row->typedir),$row->isdefault,$row->defaultname,$row->ispart,$row->namerule2,$row->moresite,$row->siteurl,$row->sitepath);
  
   $linkList .= "\n<div class=\"firsttype\"><a href=\"$typelink\"><b>".$row->typename."</b></a></div>\n\n";
  
   $linkList .= getSonClass($row->ID);
  
}
  
$dsql->Close();
  
return $linkList;
  
}
  
//获得小类栏目链接
  
function getSonClass($parentid)
  
{
  
$linkList = "";
  
$dsql = new DedeSql(false);
  
$dsql->SetQuery("Select ID,typedir,typename,isdefault From dede_arctype where reID=&#39;$parentid&#39; order by sortrank");
  
$dsql->Execute($parentid);
  
while($row=$dsql->GetObject($parentid))
  
{
  
   $typelink = GetTypeUrl($row->id,MfTypedir($row->typedir),$row->isdefault,$row->defaultname,$row->ispart,$row->namerule2,$row->moresite,$row->siteurl,$row->sitepath);
  
   $linkList .= "<li class=\"secondtype\"><a href=\"$typelink\">".$row->typename."</a></li>\n";
  
   $linkList .= getSonClass2($row->ID);
  
}
  
return $linkList;
  
}
  
function getSonClass2($parentid)
  
{
  
$linkList = "";
  
$dsql = new DedeSql(false);
  
$dsql->SetQuery("Select ID,typedir,typename,isdefault From dede_arctype where reID=&#39;$parentid&#39; order by sortrank");
  
$dsql->Execute($parentid);
  
while($row=$dsql->GetObject($parentid))
  
{
  
   $typelink = GetTypeUrl($row->id,MfTypedir($row->typedir),$row->isdefault,$row->defaultname,$row->ispart,$row->namerule2,$row->moresite,$row->siteurl,$row->sitepath);
  
   $linkList .= "<li class=\"thirdtype\"><a href=\"$typelink\">".$row->typename."</a></li>\n";
  
   $linkList .= getSonClass3($row->ID);
  
}
  
return $linkList;
  
}
  
function getSonClass3($parentid)
  
{
  
$linkList = "";
  
$dsql = new DedeSql(false);
  
$dsql->SetQuery("Select ID,typedir,typename,isdefault From dede_arctype where reID=&#39;$parentid&#39; order by sortrank");
  
$dsql->Execute($parentid);
  
while($row=$dsql->GetObject($parentid))
  
{
  
   $typelink = GetTypeUrl($row->id,MfTypedir($row->typedir),$row->isdefault,$row->defaultname,$row->ispart,$row->namerule2,$row->moresite,$row->siteurl,$row->sitepath);
  
   $linkList .= "<li class=\"fourthtype\"><a href=\"$typelink\">".$row->typename."</a></li>\n";
  
}
  
return $linkList;
  
}
/*树形栏目补充*/
登录后复制

本文地址:http://ezhuoer.com