微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

织梦DEDECMS栏目获取无限子分类的方法

织梦dedecms栏目获取无限子分类方法

提示:首先要把/include/taglib/channerl.lib.PHP 文件代码修改成以下的:
 
for($i=0;$i < $line;$i++)
{
if($col>1) $likeType .= “
for($j=0;$j<$col;$j++)
{
if($col>1) $likeType .= “
if($row=$dsql2->GetArray())
{
$row['typelink'] = $row['typeurl'] = GetoneTypeUrlA($row);
if(is_array($dtp2->CTags))
{
foreach($dtp2->CTags as $tagid=>$ctag){
if(isset($row[$ctag->GetName()]))
{
$dtp2->Assign($tagid,$row[$ctag->GetName()]);
}
elseif (preg_match(‘/^sonchannel[0-9]*$/’,$ctag->GetName()))
{
$dtp2->Assign($tagid,lib_channel_son($ctag,$row['id'],$dsql3));
}
}
}
$likeType .= $dtp2->GetResult();
}
if($col>1) $likeType .= “
}//Loop Col
if($col>1)
{
$i += $col – 1;
$likeType .= ”
}
}//Loop for $i
reset($dsql3);
$dsql2->FreeResult();
return $likeType;
}
?>
 
在模板里面用 [field:sonchannel0] [/field:sonchannel0] 调用,这个是用来取子栏目用得(使用【sonchannel+数字】作为标签名是为了防止嵌套的时候无法正确解析标签),这个的作用就是当你的栏目有很多子栏目无限分级的时候方便你取子栏目的。实例一下: