加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

thinkphp分页实现效果

发布时间:2020-12-14 14:06:14 所属栏目:大数据 来源:网络整理
导读:对于thinkphp分页的实现效果,一共分为两种一种是一种调用公共函数中的函数方法,而另一种是模型中书写分页的方法,下面就给需要的朋友来整理一下。 一、分页方法 where($where)->count();//连惯操作后会对join等操作进行重置 $m=$m1;//为保持在为定的连惯操

对于thinkphp分页的实现效果,一共分为两种一种是一种调用公共函数中的函数方法,而另一种是模型中书写分页的方法,下面就给需要的朋友来整理一下。

一、分页方法

where($where)->count();//连惯操作后会对join等操作进行重置 $m=$m1;//为保持在为定的连惯操作,浅复制一个模型 $p=new ThinkPage($count,$pagesize); $p->lastSuffix=false; $p->setConfig('header','
  • %TOTAL_ROW%条记录每页%LIST_ROW%条第%NOW_PAGE%页/共%TOTAL_PAGE%
  • '); $p->setConfig('prev','上一页'); $p->setConfig('next','下一页'); $p->setConfig('last','末页'); $p->setConfig('first','首页'); $p->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');

    $p->parameter=I('get.');

    $m->limit($p->firstRow,$p->listRows);

    return $p;
    }

    getpage方法可以放在TP框架的 Application/Common/Common/function.php,这个文档可以专门放置一些通用的方法,在哪里都可以调用(如:Controller文件,View文件等)。

    二、调用分页方法

    field(true)->where($where)->order('id desc')->select(); $this->list=$list; $this->page=$p->show();

    再是View代码

    三、

    最后就是分页的样式了,这个有些乱,因后台框架网上下载的,样式还没来的及整理,这个样式也可以自己实现,简单的。

    .pagination ul li.rows {
    line-height: 30px;
    padding-left: 5px;
    }
    .pagination ul li.rows b{color: #f00}

    .pagination ul li a,.pagination ul li span {
    float: left;
    padding: 4px 12px;
    line-height: 20px;
    text-decoration: none;
    background-color: #fff;
    background: url('../images/bottom_bg.png') 0px 0px;
    border: 1px solid #d3dbde;
    /border-left-width: 0;/
    margin-left: 2px;
    color: #08c;
    }
    .pagination ul li a:hover{
    color: red;
    background: #0088cc;
    }
    .pagination ul li.first-child a,.pagination ul li.first-child span {
    border-left-width: 1px;
    -webkit-border-bottom-left-radius: 3px;
    border-bottom-left-radius: 3px;
    -webkit-border-top-left-radius: 3px;
    border-top-left-radius: 3px;
    -moz-border-radius-bottomleft: 3px;
    -moz-border-radius-topleft: 3px;
    }
    .pagination ul .disabled span,.pagination ul .disabled a,.pagination ul .disabled a:hover {
    color: #999;
    cursor: default;
    background-color: transparent;
    }
    .pagination ul .active a,.pagination ul .active span {
    color: #999;
    cursor: default;
    }
    .pagination ul li a:hover,.pagination ul .active a,.pagination ul .active span {
    background-color: #f0c040;
    }
    .pagination ul li.last-child a,.pagination ul li.last-child span {
    -webkit-border-top-right-radius: 3px;
    border-top-right-radius: 3px;
    -webkit-border-bottom-right-radius: 3px;
    border-bottom-right-radius: 3px;
    -moz-border-radius-topright: 3px;
    -moz-border-radius-bottomright: 3px;
    }

    .pagination ul li.current a{color: #f00 ;font-weight: bold; background: #ddd}

    (编辑:李大同)

    【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

      推荐文章
        热点阅读