织梦dedecms arclist调用副栏目不显示的解决办法。
打开/include/taglib/arclist.lib.php,代码约位于295-296行,查找以下两行代码:
if($CrossID=='') $orwheres[] = ' arc.typeid IN ('.GetSonIds($typeid).')';
else $orwheres[] = ' arc.typeid IN ('.GetSonIds($typeid).','.$CrossID.')';
将其替换成以下代码:
$vicewheres = "";
$typeids = explode(",",GetSonIds($typeid));
$crossids = explode(",",$CrossID);
$typeidss = array_merge($typeids,$crossids);
$typeidss = array_unique($typeidss);
foreach($typeidss as $tid){
$liketypeid2 = ",".$tid.",";
$vicewheres.= " or CONCAT(',',arc.typeid2,',') like '%$liketypeid2%' ";
}
if($CrossID==''){
if($vicewheres!="")
$orwheres[] = ' (arc.typeid in ('.GetSonIds($typeid).') '.$vicewheres.') ';
else
$orwheres[] = ' arc.typeid in ('.GetSonIds($typeid).') ';
}else{
if($vicewheres!="")
$orwheres[] = ' (arc.typeid in ('.GetSonIds($typeid).','.$CrossID.') '.$vicewheres.') ';
else
$orwheres[] = ' arc.typeid in ('.GetSonIds($typeid).','.$CrossID.') ';
}
这种办法可以解决typeid="2"的情况下不显示副栏目的问题, 如果typeid=“2,3,8”,有多个栏目需要调用副栏目就不行了 怎么解决这个问题,找到262行, $orwheres[] = " arc.typeid IN ($typeid) "; 直接替换为:
$vicewheres = "";
foreach($typeid as $tid){
$liketypeid2 = ",".$tid.",";
$vicewheres.= " or CONCAT(',',arc.typeid2,',') like '%$liketypeid2%' ";
}
if($vicewheres!="")
$orwheres[] = " (arc.typeid in ($typeid) $vicewheres) ";
else
$orwheres[] = " arc.typeid in ($typeid) ";
问题产生的原因,看下arclist.lib.php原始代码:( typeid为主栏目id, typeid2为副栏目id)
找到246行: