zoukankan      html  css  js  c++  java
  • thinkphp 分页-自定义分页样式

    0x01

    tp分页类  /think/library/Think/Page.class.php

    调用page类

    $p = intval(I('get.p'));  //获取分页请求

    $condition['xx'] =$xx; //设置查询条件

    $m = M('xx');

    $count = count($m->select()); //计算符合条件的数据总量

    $page = new ThinkPage($count,10) //10条数据一页

    $data = $m ->where($conditon)->limit(10)->page($p)->select(); //这里采用limit+page 方法 目测ThinkCMF 有效

    $show = page ->show();  //输出到模版

    $this->assign('page',$show);

    $this->display();

    前台HTML页面写入{$page}

    分页结束

    注意:count时 多条数据传递时 选取合适的位置进行数据量计算

    0x02

    自定义分页样式

    Page.class.php

    分页样式配置 private $config数组中

    $config =array(

    'header' =>'共%TOTAL_ROW%页',

    'prev'  =>'上一页',

    'next'    =>'下一页',

    'last'   =>'%TOTAL_PAGE%',

    'search'  =>'跳转 页',

    'theme' =>'%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEAD% %SEARCH%', //自定义的键名要写里面

    );

    ... //处理URL config中数据

    //赋值到相应变量中

    $page_str = str_replace(

      array(%HEADER%,...,%SEARCH%),

      array($this->config['header'],$this->nowPage,....,$this->config['search']),

      $this->config['theme']

    );

    return "<div class='pages'>{$page_str}</div>"; //自定义相应的CSS类

    %END% =>$this_end,  //最后一页

    %TOTAL_PAGE% =>$this->totalPages, //总页面数 多少分页

    $this->totalPages =ceil($this->totalRows / $this->listRows);

    //91行附近,根据代码应该得到的是分页数目 不是总页数,

    增加一行 $this->pageCount = $this->totalPages  在str_replace里也要更改,算是BUG吧

    %TOTAL_ROW% =>pageCount

    0x03

    修改样式 在pravite config数组中添加参数或修改HTML样式,相应的str_replace()中也要替换

  • 相关阅读:
    静态与非静态(转改)
    关于odp.net的FetchSize属性
    SQL_SERVER 导oracle(转)
    win7电脑上wifi
    Oracle对象统计信息
    SQL_SERVER 连接oracle(转)
    linq in 语法
    关于引擎的设计
    温习设计模式
    技巧类
  • 原文地址:https://www.cnblogs.com/developd/p/4441136.html
Copyright © 2011-2022 走看看