|
@@ -32,7 +32,7 @@ class Cate
|
|
|
}
|
|
|
}
|
|
|
$data['cate_child'][] = array('id' => $parent_id, 'name' => '全部');
|
|
|
- $data['cate_child'] = array_merge($data['cate_child'], $this->getList($parent_id));
|
|
|
+ $data['cate_child'] = array_merge($data['cate_child'], $this->getList($parent_id, 10));
|
|
|
if ($data['cate_child']) {
|
|
|
foreach ($data['cate_child'] as &$v) {
|
|
|
$v['selected'] = 2;
|
|
@@ -42,14 +42,25 @@ class Cate
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ $data['cate_child'] = $this->getList(array('>', 0), 10);
|
|
|
+ if ($data['cate_child']) {
|
|
|
+ foreach ($data['cate_child'] as &$v) {
|
|
|
+ $v['selected'] = 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
# 获取分类列表
|
|
|
- public function getList($parent_id = 0)
|
|
|
+ public function getList($parent_id = 0, $num = false)
|
|
|
{
|
|
|
- return $this->db->select(array('parent_id' => $parent_id, 'status' => 1), array('col' => 'id,name,cdate,parent_id,`desc`'));
|
|
|
+ $set = array();
|
|
|
+ if ($num) {
|
|
|
+ $set['limit'] = '0, ' . $num;
|
|
|
+ }
|
|
|
+ return $this->db->select(array('parent_id' => $parent_id, 'status' => 1), array('col' => 'id,name,icon,cdate,parent_id,`desc`'), $set);
|
|
|
}
|
|
|
|
|
|
# 获取分类信息
|