zoukankan      html  css  js  c++  java
  • tp5最强分页 自定义model,控制器引用。只显示一页

    1.不多逼逼

    model 代码

    <?php
    namespace appcommonmodel;

    use thinkModel;
    class Fpage{
    private $page;//当前页
    private $pagenum;//总页数
    private $peytype;//矿机类型
    public function __construct($page,$pagenum,$peytype){
    $this->page=$page;
    $this->pagenum=$pagenum;
    $this->peytype=$peytype;
    }
    //首页
    private function first(){
    if($this->page==1){
    @$html.='<span>1</span>';
    }else{
    @$html.='<a href="/index/transfer/jjrecord.html?page=1&peytype='.($this->peytype).'">1...</a>';
    }
    return $html;
    }
    //上一页
    private function prev(){
    if($this->page==1){
    @$html.='<span>上一页</span>';
    }else{
    @$html.='<a href="/index/transfer/jjrecord.html?page='.($this->page-1).'&peytype='.($this->peytype).'">上一页</a>';
    }
    return $html;
    }
    //下一页
    private function next(){
    if($this->page == $this->pagenum){
    @$html.='<span>下一页</span>';
    }else{
    @$html.='<a href="/index/transfer/jjrecord.html?page='.($this->page+1).'&peytype='.($this->peytype).'">下一页</a>';
    }
    return $html;
    }
    //尾页
    private function last(){
    if($this->page==$this->pagenum){
    @$html.='<span>'.$this->pagenum.'</span>';
    }else{
    @$html.='<a href="/index/transfer/jjrecord.html?page='.($this->pagenum).'&peytype='.($this->peytype).'">...'.$this->pagenum.'</a>';
    }
    return $html;
    }
    //当前页
    private function currentpage(){
    return '<spanc>第'.$this->page.'页</spanc>';
    }
    public function pagelist(){
    return array('first'=>$this->first(),'prev'=>$this->prev(),'aaa'=>$this->currentpage(),'next'=>$this->next(),'last'=>$this->last());
    }
    }
    ?>

    2.控制器代码

    //实例化自己写的分页类
    $page=new Fpage($result->currentPage(),$result->lastPage(),$peytypes); // 第三个参数是自定义参数,例如有下来选项的时候带参数
    //echo '<pre>';print_r($page->pagelist());exit;
    //渲染到模板的分页样式
    $this->assign('page', $page->pagelist());

    3.模板渲染代码

    {$page['first']}
    {$page['prev']}
    {$page['aaa']}
    {$page['next']}
    {$page['last']}

  • 相关阅读:
    python PIL实现图片合成
    pycharm在windows中如何安装dlib?
    Git将文件上传至Github过程
    安装skimage和cv2
    ubuntu下pip的安装,更新及卸载
    pycharm专业版激活破解(亲测有效)
    docker部署tensorflow serving以及模型替换
    Keras在MNIST实现LeNet-5模型训练时的错误?
    Ubuntu中VMware tools的安装步骤
    win10执行Tensorflow,总是会报错“DLL load failed: 找不到指定的模块”的解决方式----终极版方式
  • 原文地址:https://www.cnblogs.com/roseY/p/9428110.html
Copyright © 2011-2022 走看看