/include/com.fun.php
大概110行的
function get_com_cat_children($catid,$type='int')
修改为:
function get_com_cat_children($catid,$type='int')
{
$cats = get_com_cat_list();
// $cat_children = isset($cats[$catid]['children']) ? $cats[$catid]['children'] : array();
$cat_children = array();
foreach ($cats as $cat) {
if ($cat['catid'] == $catid) {
$cat_children = $cat['children'];
break;
}
}
if(is_array($cat_children) && !empty($cat_children)) {
if($type=='int') {
$ids = array($catid); // 包含父级ID
foreach($cat_children as $child) {
$ids[] = $child['id'];
}
$result = implode(',', $ids);
} elseif($type=='array') {
$result = $cat_children;
}
} else {
if($type=='int') {
$result = $catid; // 如果没有子分类,返回当前分类ID
} elseif($type=='array') {
$result = array();
}
}
return $result;
}