public function index() { $types = M("type"); $data = $types->order("sort ASC")->select(); $arr = getList($data, ' '); //获取无限分类排序列表结果集 $typeList = getLayer($data); $this->assign("typeList", $typeList); $this->assign("types", $arr); $this->display(); }
/** * 无限分类级别排序 子类作为父类的数组值的多维数组 *@param $types array 分类结果集 *@param $name string 自定义子类下标名称 *@param $pid int 父类id *@return array 返回级别排序后结果集(多维数组) */ function getLayer($types, $name = 'child', $pid = 0) { $arr = array(); foreach ($types as $v) { if ($v['pid'] == $pid) { $v[$name] = getLayer($types, $name, $v['id']); //递归 把子类作为数组值压入数组中 $arr[$v['id']] = $v; } } return $arr; }
public function index() { $types = M('type'); $type = $types->order('sort ASC')->where('state != 2')->select(); //获取商品显示中的全部类别 $typeList = getLayer($type); //获取排序类别数组 $typeHosts = $types->order('sort ASC')->where('state = 3')->select(); //得到推荐分类 //自定义(三维)数组存放推荐分类,一维下标为父类ID,二维下标为id和name,三维下标为数字索引 foreach ($typeHosts as $v) { $typeHost[$v['pid']]['id'][] = $v['id']; $typeHost[$v['pid']]['name'][] = $v['name']; } $typeShow = $types->order('sort ASC')->where('state = 4 AND pid != 0')->select(); //得到首页展示小分类 $typeIndex = $types->order('sort ASC')->where('state = 4 AND pid = 0')->select(); //得到首页展示小分类 $brands = M('brands')->field('id,logo,type_id')->where('state = 1')->select(); //遍历得到二维数组$brandList,下标1:ID,值为品牌ID号;下标2:logo,值为品牌logo图 foreach ($type as $v) { foreach ($brands as $res) { $index = strpos($res['type_id'], "{$v['id']}"); if ($index !== false) { $brandList[$v['id']]['id'][] = $res['id']; $brandList[$v['id']]['logo'][] = $res['logo']; } } } $goods = M('goods'); $goodsList = $goods->where('state = 2')->order('addtime DESC')->select(); //获取全部销售中商品(按时间排序) $goodsHot = $goods->where('state = 2')->order('salecount ASC')->select(); //获取全部销售中商品(按销量排序) $focus = getData('posts', 'state = 2', 'sort ASC'); //获取展示中的轮播图 $news = getData('news', 'state = 2', 'sort ASC'); //获取公告、特惠新闻 $links = getData('links', 'state = 2', 'sort ASC'); //获取友情链接 //dump($typeHost); $this->assign('goods', $goodsList); $this->assign('goodsHot', $goodsHot); $this->assign('typeHost', $typeHost); $this->assign('typeShow', $typeShow); $this->assign('typeIndex', $typeIndex); $this->assign('brands', $brandList); $this->assign('types', $typeList); $this->assign('focus', $focus); $this->assign('news', $news); $this->assign('links', $links); $this->display(); }
public function index() { $types = M('type'); $type = $types->order('sort ASC')->where('state != 2')->select(); //获取商品显示中的全部类别 $typeList = getLayer($type); //获取排序类别数组 $typeHosts = $types->order('sort ASC')->where('state = 3')->select(); //得到推荐分类 //自定义(三维)数组存放推荐分类,一维下标为父类ID,二维下标为id和name,三维下标为数字索引 foreach ($typeHosts as $v) { $typeHost[$v['pid']]['id'][] = $v['id']; $typeHost[$v['pid']]['name'][] = $v['name']; } $typeShow = $types->order('sort ASC')->where('state = 4 AND pid != 0')->select(); //得到首页展示小分类 $typeIndex = $types->order('sort ASC')->where('state = 4 AND pid = 0')->select(); //得到首页展示小分类 $brands = M('brands')->field('id,logo,type_id')->where('state = 1')->select(); //遍历得到二维数组$brandList,下标1:ID,值为品牌ID号;下标2:logo,值为品牌logo图 foreach ($type as $v) { foreach ($brands as $res) { $index = strpos($res['type_id'], "{$v['id']}"); if ($index !== false) { $brandList[$v['id']]['id'][] = $res['id']; $brandList[$v['id']]['logo'][] = $res['logo']; } } } $this->assign('typeHost', $typeHost); $this->assign('typeShow', $typeShow); $this->assign('typeIndex', $typeIndex); $this->assign('brands', $brandList); $this->assign('types', $typeList); $this->display('Public:type'); }
$resultObj["mb_group_address"] = $row["mb_group_address"]; $resultObj["mb_group_email"] = $row["mb_group_email"]; $resultObj["mb_group_postcode"] = $row["mb_group_postcode"]; $resultObj["mb_group_city"] = $row["mb_group_city"]; $resultObj["mb_group_logo_path"] = $row["mb_group_logo_path"]; $resultObj["mb_group_voicetelephone"] = $row["mb_group_voicetelephone"]; } else { $resultObj["fkey_mb_group_id"] = null; } } $ajaxResponse->setResult($resultObj); $ajaxResponse->setSuccess(true); break; case "getLayerMetadata": $layerId = $ajaxResponse->getParameter("id"); getLayer($layerId); $sql = <<<SQL \t SELECT layer_id, layer_name, layer_title, layer_abstract, layer_searchable FROM layer WHERE layer_id = {$layerId}; SQL; $res = db_query($sql); $resultObj = array(); while ($row = db_fetch_assoc($res)) { foreach ($row as $key => $value) { $resultObj[$key] = $value; $e = new mb_notice("plugins/mb_metadata_server.php: get " . $value . " for " . $key); } } $sql = <<<SQL