public function _default() { $catalog_id = request('catalog_id'); $status = request('status'); $key = request('key'); $whereArr = array(); if ($catalog_id) { $whereArr[] = "`catalog_id`='{$catalog_id}'"; } if ($status) { $whereArr[] = "`status`='{$status}'"; } if ($key) { $whereArr[] = "(`title` like '%{$key}%' or `memo` like '%{$key}%')"; } if ($this->userInfo['group']['permission']['type'] != 'super') { $whereArr[] = "`author`='{$this->userInfo['id']}'"; } $where = $whereArr ? implode(' and ', $whereArr) : '1'; $page = $this->page(ArchiveModel::getCount($where)); $archives = ArchiveModel::getList($where, $this->start, $this->perpage); $uids = array(); if ($archives) { foreach ($archives as $item) { $uids[] = $item['author']; } $authors = UserModel::getByUids($uids); $this->assign('authors', $authors); } $this->assign('page', $page); $this->assign('archiveList', $archives); $this->display(); }
function _default() { //每个栏目取十个文章 $catalogIds = array_keys($this->catalogList); $where = "`catalog_id` in (" . implode(',', $catalogIds) . ") and `status`='normal'"; $archives = ArchiveModel::catalogTop($where, 20); $archives = $this->_formatArchive($archives); //取推荐的带图片的文章 $where = "`image`!='' and `recommend`=1 and `status`='normal'"; $recommendArchives = $this->_formatArchive(ArchiveModel::getList($where, 0, 20)); $this->assign('recommendArchives', $recommendArchives); $this->assign('archives', $archives); $this->display(); }