1. 分页样式为
  2. 在extend\目录下创建page目录,在page目录下创建Page.php文件,将以下代码放入文件中。
  3.  <?php
    namespace page; use think\Paginator; class Page extends Paginator
    { //首页
    protected function home() {
    if ($this->currentPage() > 1) {
    return "<a href='" . $this->url(1) . "' title='首页'>首页</a>";
    } else {
    return "<p>首页</p>";
    }
    } //上一页
    protected function prev() {
    if ($this->currentPage() > 1) {
    return "<a href='" . $this->url($this->currentPage - 1) . "' title='上一页'>上一页</a>";
    } else {
    return "<p>上一页</p>";
    }
    } //下一页
    protected function next() {
    if ($this->hasMore) {
    return "<a href='" . $this->url($this->currentPage + 1) . "' title='下一页'>下一页</a>";
    } else {
    return"<p>下一页</p>";
    }
    } //尾页
    protected function last() {
    if ($this->hasMore) {
    return "<a href='" . $this->url($this->lastPage) . "' title='尾页'>尾页</a>";
    } else {
    return "<p>尾页</p>";
    }
    } //统计信息
    protected function info(){
    return "<p class='pageRemark'>共<b>" . $this->lastPage .
    "</b>页<b>" . $this->total . "</b>条数据</p>";
    } /**
    * 页码按钮
    * @return string
    */
    protected function getLinks()
    { $block = [
    'first' => null,
    'slider' => null,
    'last' => null
    ]; $side = 3;
    $window = $side * 2; if ($this->lastPage < $window + 6) {
    $block['first'] = $this->getUrlRange(1, $this->lastPage);
    } elseif ($this->currentPage <= $window) {
    $block['first'] = $this->getUrlRange(1, $window + 2);
    $block['last'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage);
    } elseif ($this->currentPage > ($this->lastPage - $window)) {
    $block['first'] = $this->getUrlRange(1, 2);
    $block['last'] = $this->getUrlRange($this->lastPage - ($window + 2), $this->lastPage);
    } else {
    $block['first'] = $this->getUrlRange(1, 2);
    $block['slider'] = $this->getUrlRange($this->currentPage - $side, $this->currentPage + $side);
    $block['last'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage);
    } $html = ''; if (is_array($block['first'])) {
    $html .= $this->getUrlLinks($block['first']);
    } if (is_array($block['slider'])) {
    $html .= $this->getDots();
    $html .= $this->getUrlLinks($block['slider']);
    } if (is_array($block['last'])) {
    $html .= $this->getDots();
    $html .= $this->getUrlLinks($block['last']);
    } return $html;
    } /**
    * 渲染分页html
    * @return mixed
    */
    public function render()
    {
    if ($this->hasPages()) {
    if ($this->simple) {
    return sprintf(
    '%s<div class="pagination">%s %s %s</div>',
    $this->css(),
    $this->prev(),
    $this->getLinks(),
    $this->next()
    );
    } else {
    return sprintf(
    '%s<div class="pagination">%s %s %s %s %s %s</div>',
    $this->css(),
    $this->home(),
    $this->prev(),
    $this->getLinks(),
    $this->next(),
    $this->last(),
    $this->info()
    );
    }
    }
    } /**
    * 生成一个可点击的按钮
    *
    * @param string $url
    * @param int $page
    * @return string
    */
    protected function getAvailablePageWrapper($url, $page)
    {
    return '<a href="' . htmlentities($url) . '" title="第"'. $page .'"页" >' . $page . '</a>';
    } /**
    * 生成一个禁用的按钮
    *
    * @param string $text
    * @return string
    */
    protected function getDisabledTextWrapper($text)
    {
    return '<p class="pageEllipsis">' . $text . '</p>';
    } /**
    * 生成一个激活的按钮
    *
    * @param string $text
    * @return string
    */
    protected function getActivePageWrapper($text)
    {
    return '<a href="" class="cur">' . $text . '</a>';
    } /**
    * 生成省略号按钮
    *
    * @return string
    */
    protected function getDots()
    {
    return $this->getDisabledTextWrapper('...');
    } /**
    * 批量生成页码按钮.
    *
    * @param array $urls
    * @return string
    */
    protected function getUrlLinks(array $urls)
    {
    $html = ''; foreach ($urls as $page => $url) {
    $html .= $this->getPageLinkWrapper($url, $page);
    } return $html;
    } /**
    * 生成普通页码按钮
    *
    * @param string $url
    * @param int $page
    * @return string
    */
    protected function getPageLinkWrapper($url, $page)
    {
    if ($page == $this->currentPage()) {
    return $this->getActivePageWrapper($page);
    } return $this->getAvailablePageWrapper($url, $page);
    } /**
    * 分页样式
    */
    protected function css(){
    return ' <style type="text/css">
    .pagination p{
    margin:0;
    cursor:pointer
    }
    .pagination{
    height:40px;
    padding:20px 0px;
    }
    .pagination a{
    display:block;
    float:left;
    margin-right:10px;
    padding:2px 12px;
    height:24px;
    border:1px #cccccc solid;
    background:#fff;
    text-decoration:none;
    color:#808080;
    font-size:12px;
    line-height:24px;
    }
    .pagination a:hover{
    color:#077ee3;
    background: white;
    border:1px #077ee3 solid;
    }
    .pagination a.cur{
    border:none;
    background:#077ee3;
    color:#fff;
    }
    .pagination p{
    float:left;
    padding:2px 12px;
    font-size:12px;
    height:24px;
    line-height:24px;
    color:#bbb;
    border:1px #ccc solid;
    background:#fcfcfc;
    margin-right:8px; }
    .pagination p.pageRemark{
    border-style:none;
    background:none;
    margin-right:0px;
    padding:4px 0px;
    color:#666;
    }
    .pagination p.pageRemark b{
    color:red;
    }
    .pagination p.pageEllipsis{
    border-style:none;
    background:none;
    padding:4px 0px;
    color:#808080;
    }
    .dates li {font-size: 14px;margin:20px 0}
    .dates li span{float:right}
    </style>';
    }
    }

    修改  application\config.php  中的配置文件即可

 //分页配置
'paginate' => [
'type' => 'page\Page',//分页类
'var_page' => 'page',
'list_rows' => 15,
],

over!over!over!

TP5之自定义分页样式的更多相关文章

  1. GridView自定义分页样式(上一页,下一页,到第几页)

    今天要为网站做一个文章列表,发现GridView的分页样式很难看,于是结合网上的例子,自己做了一个.不是很美观,不过还是很实用的,先看下效果吧,如图(1). 图(1)GridView分页效果 自定义G ...

  2. [ Laravel 5.6 文档 ]laravel数据库操作分页(自定义分页实现和自定义分页样式)

    简介 在其他框架中,分页可能是件非常痛苦的事,Laravel 让这件事变得简单.易于上手.Laravel 的分页器与查询构建器和 Eloquent ORM 集成在一起,并开箱提供方便的.易于使用的.基 ...

  3. 修改DeDe标签Pagelist分页样式,自定义分页样式

    我们在用dede仿站的时候,调用文章列表页的分页时,我们会用到: {dede:pagelist listitem="info,index,end,pre,next,pageno" ...

  4. ThinkPHP5自定义分页样式

    1.在thinkphp/library/think/paginator/driver目录下新建文件Page.php 注意命名空间和继承 <?php namespace think\paginat ...

  5. Thinkphp5 自定义分页样式显示页码和数量

    Thinkphp5 自带的分页比较简单,本文通过修改Bootstrap类自定义显示分页的页码和数量 一.修改完成后如下图显示 二.修改Bootstrap代码: 1.为了不改动Bootstrap.php ...

  6. Laravel自定义分页样式

    <?php namespace App\Http\Controllers; use DB; use App\Http\Controllers\Controller; class UserCont ...

  7. tp5的 LayUI分页样式实现

    1.先配置你的分页参数: //分页配置 'paginate'      => [ 'type'      => 'Layui', 'var_page'  => 'page', 'li ...

  8. laravel自定义分页功能的实现:

    laravel版本:5.5.. 执行命令: php artisan vendor:publish --tag=laravel-pagination 在到 resources/views/vendor/ ...

  9. WPF自定义分页控件,样式自定义,简单易用

    WPF自定义分页控件 做了许久伸手党,终于有机会贡献一波,搜索一下WPF分页控件,还是多,但是不太通用,主要就是样式问题,这个WPF很好解决,还有一个就是分页控件嘛,只关心几个数字的变动就行了,把页码 ...

随机推荐

  1. JAVA设计模式之单例模式(转)

    本文继续介绍23种设计模式系列之单例模式. 概念: java中单例模式是一种常见的设计模式,单例模式的写法有好几种,这里主要介绍三种:懒汉式单例.饿汉式单例.登记式单例. 单例模式有以下特点: 1.单 ...

  2. stream_context_create()模拟POST/GET

    有时候,我们需要在服务器端模拟 POST/GET 等请求,也就是在 PHP 程序中去实现模拟,该怎么做到呢?或者说,在 PHP 程序里,给你一个数组,如何将这个数组 POST/GET 到另外一个地址呢 ...

  3. cocos2d-x触摸事件优先级

     CCTouchDispatcher是管理cocos2d-x中全部Touch事件派发的类, CCTouchDispatcher中包括了两个CCTouchHandler的列表, 分别存储Standa ...

  4. HashMap源代码学习笔记

        HashMap的底层主要是基于数组和链表来实现的,它之所以有相当快的查询速度主要是由于它是通过计算散列码来决定存储的位置. HashMap中主要是通过key的hashCode来计算hash值的 ...

  5. DB主从一致性的几种解决方法

    https://www.cnblogs.com/KunLunSu/p/6826247.html

  6. openwrt gstreamer实例学习笔记(三.深入了解gstreamer 的 Element)

    在前面的部分,我们简要介绍过 GstElementFactory 可以用来创建一个element的实例,但是GstElementFactory不仅仅只能做这件事,GstElementFactory作为 ...

  7. mysql insert操作

    insert的语法 INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [(col_name,...)] ...

  8. SDOI2016R1(不是解题报告)

    话说洗澡的时候想了一堆要说的,坐到电脑前反而不知所措了-- 序章 听学长说他们都是省选一周前才停的课.然而我们这届--自聪哥韩大他们在省选两周前悄悄跑路后(据说班主任非常支持),信息小组内部一呼百应, ...

  9. ajax的异步操作及页面重定向跳转

    今天主要分享一个简单的ajax的异步操作数据,用javascript也有一段时间了,刚开始看到一些页面在没有页面刷新的情况下就可以实现数据的保存或者获取,觉得挺不可思议的,感觉速度很快,做了几个项目之 ...

  10. MySQL优化之——触发器

    转载请注明出处:http://blog.csdn.net/l1028386804/article/details/46763665 触发器是一个特殊的存储过程,不同的是存储过程要用CALL来调用,而触 ...