muban大师 发表于 2020-11-15 11:09:21

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

织梦DEDECMS栏目获取无限子分类的方法 。
       
        提示:首先要把/include/taglib/channerl.lib.php 文件的代码修改成以下的:
       
        for($i=0;$i
        {
        if($col>1) $likeType .= “\r\n”;
        for($j=0;$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”;
        }//Loop Col
        if($col>1)
        {
        $i += $col – 1;
        $likeType .= ” \r\n”;
        }
        }//Loop for $i
        reset($dsql3);
        $dsql2->FreeResult();
        return $likeType;
        }
        ?>
       
        在模板里面用 调用,这个是用来取子栏目用得(使用【sonchannel+数字】作为标签名是为了防止嵌套的时候无法正确解析标签),这个的作用就是当你的栏目有很多子栏目无限分级的时候方便你取子栏目的。实例一下:
       
       
                            {dede:channel type=’son’ typeid=’16′}
             [*,
             
             
             [*,
                                     
                [field:sonchannel1,
                [*,
                                        
                 [field:sonchannel2,
                 [*,
                                           
                [field:sonchannel3,
                [*,
                [/field:sonchannel3,
                                              
                                           
                 [/field:sonchannel2,
                                           
                                        
                [/field:sonchannel1,
                                        
                                  
             
             
                            
             {/dede:channel}
                      
       
        以上typeid中的数字改成你的大分类的ID即可,因为在DEDE官方论坛没找到,所以这里发上来,希望能方便有用者。
        注意:未免出错修改文件前请做好备份,以上代码可能有些引号又被自动转成全角的了,请修改成半角的 。
页: [1]
查看完整版本: 织梦DEDECMS栏目获取无限子分类的方法