thinkPHP3.2实现分页自定义样式的方法(2)

public function index(){ $obj=M("news"); $count = $obj->where('status=1 and classID=74 ')->count();// 查询满足要求的总记录数 $limit = 10; $Page = new \Think\Page($count,$limit);// 实例化分页类 传入总记录数和每页显示的记录数(25) $show = $Page->show();// 分页显示输出 $list = $obj->where('status=1 and classID=74 ')->order('writetime desc')->limit($Page->firstRow.','.$Page->listRows)->select(); $firstlist = $obj->where('status=1 and classID=74 and Indexfirst=1')->order('writetime desc')->limit(4)->select(); $this->assign('firstlist',$firstlist); $this->assign('page',$show);// 赋值分页输出 $this->assign('list',$list); $this->display(); }

3. 接下来是View层,样式控制。page.css文件

.b-page { background: #fff; box-shadow: 0px 1px 2px 0px #E2E2E2; } .page { width: 100%; background: #FFF; text-align: center; overflow: hidden; font-size:14px; margin-top:50px; } .page .first, .page .prev, .page .current, .page .num, .page .current, .page .next, .page .end { padding: 8px 16px; margin: 0px 5px; display: inline-block; color: #144970; border: 1px solid #F2F2F2; border-radius: 5px; } .page .first:hover, .page .prev:hover, .page .current:hover, .page .num:hover, .page .current:hover, .page .next:hover, .page .end:hover { text-decoration: none; background: #F8F5F5; } .page .current { background-color: #144970; color: #FFF; border-radius: 5px; } .page .current:hover { text-decoration: none; background: #144970; } .page .not-allowed { cursor: not-allowed; }

更多关于thinkPHP相关内容感兴趣的读者可查看本站专题:《ThinkPHP入门教程》、《thinkPHP模板操作技巧总结》、《ThinkPHP常用方法总结》、《codeigniter入门教程》、《CI(CodeIgniter)框架进阶教程》、《Zend FrameWork框架入门教程》及《PHP模板技术总结》。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/3c496a948524da38eaea79ad7682785f.html