public function actionIndex() { $this->poiType = zmf::filterInput($_GET['type']); $this->poiOrder = zmf::filterInput($_GET['order']); $areaid = zmf::filterInput($_GET['areaid']); if (!$this->poiOrder || !in_array($this->poiOrder, array('1', '2'))) { $this->poiOrder = '1'; } $where = $order = ''; if ($areaid) { $extra = Area::getAreaInfo($areaid); $areaIds = $extra['areaIds']; $areaInfo = $extra['areaInfo']; if ($areaIds) { $where .= " areaid IN({$areaIds}) AND "; } } $_typename = Position::exClassify($this->poiType); if ($this->poiType && $_typename && !is_array($_typename)) { $where .= " classify='{$this->poiType}' AND "; } else { $this->poiType = ''; $_typename = '的景点、酒店、餐厅及购物'; } if ($this->poiOrder == '1') { $order = ' ORDER BY score DESC'; } elseif ($this->poiOrder == '2') { $order = ' ORDER BY scorer DESC'; } //获取景点列表 $sql = "SELECT id,title_cn,title_en,title_local,address_cn,address_en,address_local,score,scorer,attach,lat,`long`,faceimg,classify FROM {{position}} WHERE {$where} forWedding=1 AND status=" . Posts::STATUS_PASSED . $order; Posts::getAll(array('sql' => $sql), $pages, $posts); //获取所有受推荐地区 $areas = Area::getTops(0); //面包屑 $breads[] = CHtml::link('目的地', array('position/index')); if ($areaInfo) { $breads[] = $areaInfo['title']; } //页面SEO $this->pageTitle = '目的地 - ' . zmf::config('sitename'); $this->render('index', array('posts' => $posts, 'pages' => $pages, 'areas' => $areas, 'breads' => $breads, 'areaId' => $areaid)); }
<ul class="nav nav-tabs" role="tablist"> <li <?php if (!$this->poiType) { echo 'class="active"'; } ?> ><?php $attr = array('position/index', 'areaid' => $areaId, 'order' => $this->poiOrder); $attr = array_filter($attr); echo CHtml::link('全部', $attr); ?> </li> <?php $types = Position::exClassify(); foreach ($types as $type => $title) { ?> <li <?php if ($this->poiType == $type) { echo 'class="active"'; } ?> ><?php $attr = array('position/index', 'areaid' => $areaId, 'type' => $type, 'order' => $this->poiOrder); $attr = array_filter($attr); echo CHtml::link($title, $attr); ?> </li> <?php } ?> <li class="dropdown pull-right"><a href="#" id="order-poi-type" class="dropdown-toggle" data-toggle="dropdown" ><?php