Home  >  Article  >  CMS Tutorial  >  How to get N-level list link tree menu of any column in DedeCms

How to get N-level list link tree menu of any column in DedeCms

藏色散人
藏色散人Original
2019-12-14 10:22:041961browse

How to get N-level list link tree menu of any column in DedeCms

How does DedeCms obtain the N-level list link tree menu of any column?

DedeCms obtains the N-level list link tree menu of any column. The editor reminds that the following modification method is applicable to the default table prefix of DedeCMS. If you modified it during installation, please pay attention to the modification.

Recommended learning: Dream Weaver cms

Add the following code at the bottom of the \include\channelunit.func.php file:

/*树形栏目补充,获取二级,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;
  
}
/*树形栏目补充*/

2. In the template Just use

{dede:channel function=&#39;getProductTree(2)&#39;}{/dede:channel} 

to call it. Here 2 in getProductTree(2) is the column ID of the product display. If yours is different, please modify it accordingly.

The above is the detailed content of How to get N-level list link tree menu of any column in DedeCms. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn