public function index($id = 0) { $category = $this->category($id); $this->assign('category', $category); // 赋值分页输出 $map = array(); $map['category_id'] = $category['id']; $map['status'] = 1; $num = 15; $Document = M('document'); $lists = $Document->where($map)->order('create_time')->page($_GET['p'] . ',' . $num)->select(); foreach ($lists as $key => $val) { $lists[$key]['url'] = U('Article/detail', array('id' => $val['id'])); } $this->assign('lists', $lists); // 赋值数据集 $count = $Document->where($map)->count(); // 查询满足要求的总记录数 $_page = article_pages($count, $num); $this->assign('_page', $_page); // 赋值分页输出 $Catelist = D('category'); $cateList = $Catelist->getTree(2, false); $this->assign('cateList', $cateList); // 分类树 $this->display(); }
public function index() { $catid = I('get.catid', ''); $zone = I('get.zone', ''); $sub_id = I('get.sub_id', ''); $pageNum = 6; $nowPage = I('get.p', 1); $firstRow = ($nowPage - 1) * $pageNum; $map = array(); $map['visa_catid'] = $catid; $map['zone'] = $zone; $map['sub_id'] = $sub_id; $map['_logic'] = 'OR'; $where['_complex'] = $map; $where['status'] = 1; $Visa = M('Visa'); $visa_lists = $Visa->where($where)->order('sort asc,update_time desc')->limit($firstRow, $pageNum)->select(); foreach ($visa_lists as $k => $val) { $visa_lists[$k]['is_yaoqing'] = $val['is_yaoqing'] ? '需要' : '不需要'; $visa_lists[$k]['is_mianshi'] = $val['is_mianshi'] ? '需要' : '不需要'; $visa_lists[$k]['url'] = U('Visa/show', array('id' => $val['visa_id'])); $visa_lists[$k]['image'] = get_cover($val['cover_id'], 'path'); $visa_lists[$k]['zone'] = get_visa_field($val['zone'], 'title'); } $count = $Visa->where($where)->count(); $page = article_pages($count, $pageNum); $sub_ids = C(QZ_TYPE); $this->assign('sub_ids', $sub_ids); $this->assign('visa_lists', $visa_lists); $this->assign('_page', $page); $this->display(); }
public function index() { $catid = I('get.catid', ''); $zone = I('get.zone', ''); $sub_id = I('get.sub_id', ''); $keyword = I('get.keyword', ''); $pageNum = 6; $nowPage = I('get.p', 1); $firstRow = ($nowPage - 1) * $pageNum; $map = array('status' => 1); if (!empty($catid)) { $map['visa_catid'] = $catid; } if (!empty($zone)) { $map['zone'] = $zone; } if (!empty($sub_id)) { $map['sub_id'] = $sub_id; } if (!empty($keyword)) { $map['title'] = array('like', '%' . $keyword . '%'); } $Visa = M('Visa'); $visa_lists = $Visa->where($map)->order('sort desc,update_time desc')->limit($firstRow, $pageNum)->select(); // echo $Visa->_sql(); foreach ($visa_lists as $k => $val) { $visa_lists[$k]['is_yaoqing'] = $val['is_yaoqing'] ? '需要' : '不需要'; $visa_lists[$k]['is_mianshi'] = $val['is_mianshi'] ? '需要' : '不需要'; $visa_lists[$k]['url'] = U('Visa/show', array('id' => $val['visa_id'])); $visa_lists[$k]['image'] = get_cover($val['cover_id'], 'path'); $visa_lists[$k]['zone'] = get_visa_field($val['zone'], 'title'); } $count = $Visa->where($map)->count(); $page = article_pages($count, $pageNum); $sub_ids = C(QZ_TYPE); $this->assign('sub_ids', $sub_ids); $this->assign('visa_lists', $visa_lists); $this->assign('_page', $page); $this->display(); }
public function index() { $LineView = D('LineView'); $catid = I('get.catid', 1); $pageNum = 10; $nowPage = I('get.p', 1); $firstRow = ($nowPage - 1) * $pageNum; $souso = array('catid' => $catid); $map = array('type_id' => $catid, 'end_time' => array('gt', NOW_TIME), 'is_default' => 1); // 搜索关键词 $keyword = I('keyword', '', 'trim'); if (!empty($keyword) && $keyword != '请输入主题或关键词') { $map['title'] = array('like', '%' . $keyword . '%'); $souso['keyword'] = $keyword; } // 出发城市 $start = I('start', '', 'trim'); if (!empty($start)) { if (strpos($start, '-') === false) { $map['start'] = array('like', '%' . $start . '%'); } else { $keywords = explode('-', $start); foreach ($keywords as $key => $value) { $keywords[$key] = '%' . $value . '%'; } $map['start'] = array('like', $keywords, 'OR'); } $souso['start'] = $start; } // 目的地 $dest = I('dest'); if (!empty($dest)) { $map['type_id'] = $dest; $souso['dest'] = $dest; } // 参团性质 $ct_type = I('ct_type', 0, 'intval'); if (!empty($ct_type)) { $map['ct_type'] = $ct_type; $souso['ct_type'] = $ct_type; } // 线路类型 $l_type = I('l_type', 0, 'intval'); if (!empty($l_type)) { $map['l_type'] = $l_type; $souso['l_type'] = $l_type; } // 旅行天数 $daynum = I('daynum', 0, 'intval'); if (!empty($daynum)) { $map['daynum'] = array('elt', $daynum); $souso['daynum'] = $daynum; } // 价格区间 $price = I('price'); if (!empty($price)) { list($p1, $p2) = explode('-', $price); if ($p1 == 0 && $p2 > 0) { $map['price'] = array('elt', $p2); } elseif ($p1 > 0 && $p2 == 0) { $map['price'] = array('egt', $p1); } elseif ($p1 > 0 && $p2 > 0) { $map['price'] = array(array('egt', $p1), array('elt', $p2)); } $souso['price'] = $price; } // sort $sort = I('sort'); switch ($sort) { case 'base_order': $order = 'base_order desc, end_time desc, line_id desc'; break; case 'price': $order = 'price desc, end_time desc, line_id desc'; break; default: $order = 'end_time desc, line_id desc'; break; } $souso['sort'] = $sort; // $map['cname'] = '北京'; $list = $LineView->field('')->where($map)->order($order)->limit($firstRow, $pageNum)->group('line_id')->select(); // echo $LineView->_sql(); foreach ($list as $key => $val) { $list[$key]['start_date'] = get_start_date($val['date_price_data']); $list[$key]['img'] = get_cover(array_shift(explode(',', $val['images'])), 'path'); $list[$key]['url'] = U('Line/show', array('id' => $val['line_id'])); } $categorys = array(); foreach ($this->line_cate as $value) { if ($value['id'] == $catid) { $categorys = $value; break; } else { foreach ($value['_'] as $val) { if ($val['id'] == $catid) { $categorys = $val; break; } else { continue; } } } } $this->assign('categorys', $categorys); $count = $LineView->where($map)->count(); $_page = article_pages($count, $pageNum); $this->assign('list', $list); $this->assign('souso', $souso); $this->assign('_page', $_page); $this->display(); }