在includechannelunit.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>nn";
- $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='$parentid' 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='$parentid' 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='$parentid' order by sortrank");
- $dsql->execute($parentid);
- while($row=$dsql->getobject($parentid))
- { //开源软件:Vevb.com
- $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;
- }
- /*树形栏目补充*/
- ----------------------------------------------------------------------------
在模板里用:
{dede:channel function='getproducttree(2)'}{/dede:channel}
调用即可,这里getproducttree(2)中的 2 是产品展示的栏目id,如果你的是其他的,请作相应修改.
新闻热点
疑难解答