function index() { $page = 1; $url = __SELF__; $url = strpos($url, '?') !== false ? "{$url}&" : "{$url}?"; $pageRows = 18; $tags = M('Tags'); $where = I('get.'); if (array_key_exists('page', $where)) { $page = $where['page']; unset($where['page']); } $totalRows = $tags->count(); $totalPage = ceil($totalRows / $pageRows); $tagsArr = $tags->limit($pageRows * ($page - 1), $pageRows)->select(); /* 分页开始 */ $params = array($totalPage, $pageRows, $page); $pagenav = new \Org\Pagenav($params); $pagenav->setSynthesizeStrings('Frist', 'Prev', '', 'Next', 'Last', 5); $synthesizeAnc = $pagenav->createNavigateSynthesize(); $curPage = array_pop($synthesizeAnc); /* 分页结束 */ $this->assign('tags', $tagsArr); $this->assign('pagebtn', $synthesizeAnc); $this->assign('page', $curPage); $this->assign('totalrows', $totalRows); $this->assign('pagerows', $pageRows); $this->assign('url', $url); $this->display(); }
function index() { $page = 1; $keyword = ""; $url = __SELF__; $url = strpos($url, '?') !== false ? "{$url}&" : "{$url}?"; $pageRows = 1; $article = M('Article'); $where = I('get.'); if (array_key_exists('page', $where)) { $page = $where['page']; unset($where['page']); } if (array_key_exists('keyword', $where) && !empty($where['keyword'])) { $keyword = $where['keyword']; unset($where['keyword']); $comp['title'] = array('like', "%{$keyword}%"); $comp['tags'] = $keyword; $comp['_logic'] = 'or'; $where['_complex'] = $comp; } if ($where['type'] == 'all') { unset($where['type']); } $totalRows = $article->where($where)->count(); $totalPage = ceil($totalRows / $pageRows); $articleArr = $article->where($where)->limit($pageRows * ($page - 1), $pageRows)->select(); /* 分页开始 */ $params = array($totalPage, $pageRows, $page); $pagenav = new \Org\Pagenav($params); $arrowAnc = $pagenav->createNavigateArrow(); $pagenav->setSynthesizeStrings('Frist', 'Prev', '', 'Next', 'Last', 5); $synthesizeAnc = $pagenav->createNavigateSynthesize(); $curPage = array_pop($synthesizeAnc); /* 分页结束 */ $this->assign('articles', $articleArr); $this->assign('pagebtn', $synthesizeAnc); $this->assign('page', $curPage); $this->assign('totalrows', $totalRows); $this->assign('pagerows', $pageRows); $this->assign('url', $url); $this->assign('keyword', $keyword); $this->display(); }