public function index() { import('ORG.Util.Page'); $article = new ArticleViewModel(); $keyword = I('keyword', NULL); $ftype = I('ftype', NULL); $where = array(); if (!empty($keyword) && !empty($ftype)) { $where[$ftype] = array('like', '%' . $keyword . '%'); } $type_id = I('type_id', 0); if (0 < $type_id) { $where['type_id'] = $type_id; } $count = $article->where($where)->count(); $page = new Page($count, 8); $show = $page->show(); $this->assign('show', $show); $articlelist = $article->order('id desc')->where($where)->limit($page->firstRow . ',' . $page->listRows)->select(); $type = M('article_type')->select(); $this->assign('type_list', $type); $this->assign('count', $count); $this->assign('articlelist', $articlelist); $this->display(); }
/** * 文章显示页面 */ function index() { import('ORG.Util.Page'); $articles = new ArticleViewModel(); //搜索项 $keyword = $_POST['keyword']; if (is_numeric($keyword)) { $where['Article.id'] = array('eq', $keyword); } else { $where['Article.title'] = array('like', '%' . $keyword . '%'); } //切换文章状态 $change_pub = trim($_POST['change_published']); if ($change_pub) { $where['Article.published'] = array('eq', $change_pub); } //传值在前台判断 $this->assign('change_pub', $change_pub); //得到分页需要的总文章数 $count = $articles->where($where)->count(); $page = new Page($count, C('PAGESIZE')); $show = $page->show(); $this->assign("show", $show); //得到文章数据 $list = $articles->order('Article.id DESC')->where($where)->limit($page->firstRow . ',' . $page->listRows)->select(); $this->assign('alist', $list); //分配配置中的每页显示多少文章到前台 $this->assign('pagesize', C('PAGESIZE')); $this->display(); }
/** * 查看分类下属文章 */ function look() { import('ORG.Util.Page'); $articles = new ArticleViewModel(); $cat_id = $_GET['id']; $where = array('catid' => array('eq', $cat_id)); $count = $articles->where($where)->count(); $page = new Page($count, C('PAGESIZE')); $show = $page->show(); $list = $articles->where($where)->limit($page->firstRow . ',' . $page->listRows)->select(); $this->assign("show", $show); $this->assign('art_info', $list); $this->display(); }