织梦多个栏目arclist调用副栏目不显示的解决办法

Posted 菜鸟技术博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了织梦多个栏目arclist调用副栏目不显示的解决办法相关的知识,希望对你有一定的参考价值。

织梦arclist调用副栏目不显示,网上关于这个问题的解决办法有很多,其中一种是:

打开/include/taglib/arclist.lib.php,代码约位于295-296行(我目前用的DedeCMS最新版 5.7 SP1),查找以下两行代码:
if($CrossID==‘‘) $orwheres[] = ‘ arc.typeid IN (‘.GetSonIds($typeid).‘)‘;
else $orwheres[] = ‘ arc.typeid IN (‘.GetSonIds($typeid).‘,‘.$CrossID.‘)‘;
  将其替换成以下代码:
if($CrossID==‘‘) $orwheres[] = ‘ (arc.typeid IN (‘.GetSonIds($typeid).‘) OR arc.typeid2 IN (‘.GetSonIds($typeid).‘)) ‘;
else $orwheres[] = ‘ (arc.typeid IN (‘.GetSonIds($typeid).‘,‘.$CrossID.‘) OR arc.typeid2 IN (‘.GetSonIds($typeid).‘,‘.$CrossID.‘)) ‘;

这种办法可以解决typeid="2"的情况下, 如果typeid=“2,3,8”,有多个栏目需要调用副栏目就不行了

怎么解决这个问题,找到262行, $orwheres[] = " arc.typeid IN ($typeid) ";

直接替换为: $orwheres[] = " arc.typeid IN ($typeid) or arc.typeid2 IN ($typeid)";


问题产生的原因,看下arclist.lib.php原始代码:( typeid为主栏目id, typeid2为副栏目id)

    找到246行:
 
      //指定了多个栏目时,不再获取子类的id
      if( preg_match(‘#,#‘, $typeid) ) //如果typeid字段匹配逗号, 就是说typeid调用多个栏目,例如:typeid=“2,3,8”
             {
                //指定了getall属性或主页模板例外
                if($getall==1 || empty($refObj->Fields[‘typeid‘]))
                {
                    $typeids = explode(‘,‘, $typeid);
                    foreach($typeids as $ttid) {
                        $typeidss[] = GetSonIds($ttid);
                    }
                    $typeidStr = join(‘,‘, $typeidss);
                    $typeidss = explode(‘,‘, $typeidStr);
                    $typeidssok = array_unique($typeidss);
                    $typeid = join(‘,‘, $typeidssok);
                }
 
                $orwheres[] = " arc.typeid IN ($typeid)"; //导致typeid=‘2,3,8‘情况下不能调用副栏目问题产生的地方
            }
            else //如果typeid不匹配逗号,就是调用一个栏目 例如 typeid="2"
            {
               //处理交叉栏目
                $CrossID = ‘‘;
                if($ctag->GetAtt(‘cross‘)==‘1‘)
                {
                    $arr = $dsql->GetOne("SELECT `id`,`topid`,`cross`,`crossid`,`ispart`,`typename` FROM `dede_arctype` WHERE id=‘$typeid‘ ");
                    if( $arr[‘cross‘]==0 || ( $arr[‘cross‘]==2 && trim($arr[‘crossid‘]==‘‘) ) )
                    {
                        $orwheres[] = ‘ arc.typeid IN (‘.GetSonIds($typeid).‘)‘;
                  }
                    else
                    {
                        $selquery = ‘‘;
                        if($arr[‘cross‘]==1) {
                            $selquery = "SELECT id,topid FROM `dede_arctype` WHERE typename LIKE ‘{$arr[‘typename‘]}‘ AND id<>‘{$typeid}‘ AND topid<>‘{$typeid}‘ ";
                        }
                        else {
                            $arr[‘crossid‘] = preg_replace(‘#[^0-9,]#‘, ‘‘, trim($arr[‘crossid‘]));
                            if($arr[‘crossid‘]!=‘‘) $selquery = "SELECT id,topid FROM `dede_arctype` WHERE id IN(‘{$arr[‘crossid‘]}‘) AND id<>‘{$typeid}‘ AND topid<>‘{$typeid}‘ ";
                        }
                        if($selquery!=‘‘)
                        {
                            $dsql->SetQuery($selquery);
                            $dsql->Execute();
                            while($arr = $dsql->GetArray())
                            {
                                $CrossID .= ($CrossID==‘‘ ? $arr[‘id‘] : ‘,‘.$arr[‘id‘]);
                            }
                        }
                    }
                }
                if($CrossID==‘‘) $orwheres[] = ‘ arc.typeid IN (‘.GetSonIds($typeid).‘)‘;
                else $orwheres[] = ‘ arc.typeid IN (‘.GetSonIds($typeid).‘,‘.$CrossID.‘)‘; //导致typeid=‘2‘情况下不能调用副栏目问题产生的地方
            }

    原创文章,转载请注明出处:http://www.niurenzm.com/jiaocheng/201506031343.html

以上是关于织梦多个栏目arclist调用副栏目不显示的解决办法的主要内容,如果未能解决你的问题,请参考以下文章

让织梦内容页arclist标签的当前文章标题加亮显示

织梦列表页怎么以栏目关键词来调用文章

织梦栏目列表如何调用相关文章

织梦设置栏目列表排序方式

织梦DedeCMS调用二级子栏目或者多级栏目解决方法

dedecms织梦如何调用指定的多个栏目导航