Exemplo n.º 1
0
 public function index()
 {
     $User = D($this->selectmodel);
     // 实例化User对象
     import('@.Util.Page');
     // 导入分页类
     $where = array();
     $this->setwhere($where);
     $count = $User->where($where)->count();
     // 查询满足要求的总记录数
     $Page = new Page($count, 25);
     // 实例化分页类 传入总记录数和每页显示的记录数
     $Page->setConfig('theme', "%upPage% %linkPage% %downPage%");
     $show = $Page->show();
     // 分页显示输出
     // 进行分页数据查询 注意limit方法的参数要使用Page类的属性
     $list = $User->where($where)->order($this->orderby)->limit($Page->firstRow . ',' . $Page->listRows)->select();
     // echo D()->getLastSql();
     $this->assign('list', $list);
     // 赋值数据集
     $this->assign('page', $show);
     // 赋值分页输出
     $this->display("index");
     // 输出模板
 }
Exemplo n.º 2
0
 public function index()
 {
     // $data = Db::table('article')->get();
     // $count = count($data);
     // // p($_SERVER);exit;
     // // // p($count);exit;
     // // // p(Page::getTotalPage($data));exit;
     // $page = Page::row(10)->pageNum(3)->make($count);
     // $data = Db::table('article')->
     // limit(Page::limit())->get();
     // $num = Page::getTotalPage($page);
     // // p($num);exit;
     // View::with('page',$page)->with('data',$data)->make();
     $data = Db::table('article')->get();
     // p($data);
     $page = Page::row(10)->pageNum(4)->make(count($data));
     $data = Db::table('article')->limit(Page::limit())->get();
     p(Page::limit());
     $num = Page::getTotalPage();
     p($num);
     View::with('page', $page)->with('data', $data)->make();
 }
Exemplo n.º 3
0
 public function category()
 {
     if (IS_POST) {
         define('THEME_PATH', './Template/');
         $id = I('cid', '', 'intval');
         if (!$id) {
             $this->error('请选择栏目!', U('Html/category'));
             exit;
         }
         $where = array('is_show' => 1, 'id' => $id);
         $cate = M('cate')->where($where)->select();
         foreach ($cate as $k => $v) {
             $_GET['cid'] = $v['id'];
             $htmldir = './Html/' . C('WEBSTYLE') . '/' . $v['list_html'] . '/';
             $list_style = reset(explode('.', $cate['list_style']));
             $list = $list_style ? $list_style : 'list';
             $htmlfile = C('WEBSTYLE') . '/' . $list;
             $this->buildHtml('index', $htmldir, $htmlfile, 'utf-8');
             import('Common/Org/Util/Page');
             for ($i = 1; $i <= \Page::$staticTotalPage; $i++) {
                 $_GET['page'] = $i;
                 $pageurl = './Html/' . C('WEBSTYLE') . '/' . $v['list_html'] . '/';
                 \Page::$staticUrl = $pageurl . '{page}.html';
                 $this->buildHtml($i, $htmldir, $htmlfile, 'utf-8');
             }
             copy($htmldir . '1.html', $htmldir . 'index.html');
         }
         $this->success('成功生成栏目页静态!', U('Index/welcome'));
     } else {
         $where = array('is_show' => 1, 'is_html' => 1);
         $cate = M('cate')->where($where)->order('sort asc')->select();
         import('Common/ORG/Util/Data');
         $MyCate = new \Data();
         $this->cate = $MyCate::tree($cate, 'name');
         $this->display();
     }
 }
Exemplo n.º 4
0
 public function createCategoryConfig()
 {
     if (IS_POST) {
         $cat = Db::table('category')->get();
         $data = array();
         foreach ($cat as $c) {
             $_GET['id'] = $c['id'];
             ob_start();
             $obj = new \Home\Controller\IndexController();
             $obj->category();
             ob_get_clean();
             // $c['id'] = 20;
             $num = Page::getTotalPage();
             $data[$c['id']] = $num;
         }
         F('__HTML__', $data);
         go('createCategory');
     } else {
         F('__HTML__', '[del]');
         View::make();
     }
 }
 function pageNavgation($count, $pageSize = 10)
 {
     import('@.ORG.Page');
     $page = new Page($count, $pageSize);
     $page->setConfig('header', '条记录');
     $page->setConfig('theme', '<span class="pagestyle" style="color:blue">共%totalRow%%header%</span> <span class="pagestyle">当前%nowPage%&nbsp;/&nbsp;%totalPage% 页</span> %first% %upPage% %linkPage% %downPage% %end%');
     return $page;
 }