Ejemplo n.º 1
0
 /**
  * 分类页面显示首页
  */
 function index()
 {
     import('ORG.Util.Page');
     $categorys = new CategoryViewModel();
     //判断是否有搜索
     $keyword = trim($_POST['keyword']);
     //搜索项
     if (is_numeric($keyword)) {
         $where['Category.id'] = array('eq', $keyword);
     } else {
         $where['Category.title'] = array('like', '%' . $keyword . '%');
     }
     //切换状态
     $change_pub = trim($_POST['change_published']);
     if ($change_pub) {
         $where['Category.published'] = array('eq', $change_pub);
     }
     //传值在前台判断
     $this->assign('change_pub', $change_pub);
     //得到分页需要的总文章数
     $count = $categorys->where($where)->count();
     $page = new Page($count, C('PAGESIZE'));
     $show = $page->show();
     $this->assign("show", $show);
     //得到文章数据
     $list = $categorys->where($where)->order('Section.title,Category.id DESC')->limit($page->firstRow . ',' . $page->listRows)->select();
     $this->assign('clist', $list);
     //分配配置中的每页显示多少文章到前台
     $this->assign('pagesize', C('PAGESIZE'));
     $this->display();
 }
Ejemplo n.º 2
0
 /**
  * 查看单元下属分类
  */
 function look()
 {
     import('ORG.Util.Page');
     $categorys = new CategoryViewModel();
     $sec_id = $_GET['id'];
     $where = array('sectionid' => array('eq', $sec_id));
     $count = $categorys->where($where)->count();
     $page = new Page($count, C('PAGESIZE'));
     $show = $page->show();
     $list = $categorys->where($where)->limit($page->firstRow . ',' . $page->listRows)->select();
     $this->assign("show", $show);
     $this->assign('cat_info', $list);
     $this->display();
 }