Think PHP 3.2 分页

通过 limit,page分页

控制器:

$rel = $member->limit(5)->page($_GET['p'])->select();
$mecount = $member->select();
$Pages  = new \Think\Page(count($mecount),5);// 实例化分页类 传入总记录数和每页显示的记录数

$Pages->setConfig('header','<span class="rows">共 %TOTAL_ROW% 位会员</span>');
$Pages->setConfig('prev','上一页');
$Pages->setConfig('next','下一页');
$Pages->setConfig('first','首页');//第一页
$Pages->setConfig('last','末页');//最后一页

$show = $Pages->show();// 分页显示输出
$this->assign('page', $show); 

Page.class.php

将第 33行:

'theme'  => '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%',

改为:

'theme'  => '%HEADER% %FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%',

// %HEADER% 总条数103行:
//第一页
if($this->totalPages > $this->rollPage && ($this->nowPage - $now_cool_page) >= 1){
            $the_first = '<a class="first" href="' . $this->url(1) . '">' . $this->config['first'] . '</a>';
        }
改为:

 if(!empty($down_page) || !empty($up_page)){
            $the_first = '<a class="first" href="' . $this->url(1) . '">' . $this->config['first'] . '</a>';
       }

//显示 首页108行:

//最后一页

if($this->totalPages > $this->rollPage && ($this->nowPage + $now_cool_page) < $this->totalPages){
            $the_end = '<a class="end" href="' . $this->url($this->totalPages) . '">' . $this->config['last'] . '</a>';
        }

改为:

if(!empty($down_page) || !empty($up_page)){   
            $the_end = '<a class="end" href="' . $this->url($this->totalPages) . '">' . $this->config['last'] . '</a>';

        }

第92行:

$this->lastSuffix && $this->config['last'] = $this->totalPages;

改为:

$this->lastSuffix = $this->totalPages;

//显示 末页

模板:

<div class='page'>{$page}</div>

css样式:

.page{ text-align:center; margin-top:20px; height:30px;}
.page a,.page span{ margin-left:10px;}
.page .num{width:50px;border:1px solid #CCC;margin-left:5px;text-decoration:none; padding:2px 15px;}
.current{background:#34cdf6;width:50px;border:1px solid #CCC;margin-left:10px;color:#036cb4;padding:2px 15px;}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值