在使用Dedecms进行网站建设时,有时我们需要获取栏目下的无限子分类。以下是一种实现方法,帮助您轻松完成这一需求。

首先,需要修改/include/taglib/channel.lib.php文件中的代码。以下是修改后的代码内容:


for($i=0; $i < $line; $i++) {
    if($col>1) $likeType .= "
\\\\r\\\\n"; for($j=0; $j<$col; $j++) { if($col>1) $likeType .= "
\\\\r\\\\n"; 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 .= "
\\\\r\\\\n"; } if($col>1) { $i += $col - 1; $likeType .= "
\\\\r\\\\n"; } } reset($dsql3); $dsql2->FreeResult(); return $likeType;

修改完成后,请确保保存文件并上传到服务器替换原有文件。接下来,在模板中使用以下标签调用子栏目:

例如: