• CI框架3.x 之分页类使用


    一、效果图

     二、代码

    public function articlePage()
        {
            $cat_id = $this->input->get("catid");
            $search = $this->input->get("search");
            $current_page = intval($this->input->get("per_page")); //获取当前分页页码数
            $this->load->library('pagination');//加载分页库
            $count = $this->article_model->getArticleCount($cat_id, $search);
            $config['base_url'] = site_url('home/index/index?catid='.$cat_id.'&search='.$search);
            $config['total_rows'] = $count;
            $config['per_page'] = 2;
    
            $config['num_links'] = 3;
    
            $config['first_link'] = '首页';
            $config['prev_link'] = '上一页';
            $config['next_link'] = '下一页';
            $config['last_link'] = '末页';
    
            $config['full_tag_open'] = '<ul class="">';
            $config['full_tag_close'] = '</ul>';
    
            $config['first_tag_open'] = '<li>';
            $config['first_tag_close'] = '</li>';
    
            $config['prev_tag_open'] = '<li>';
            $config['prev_tag_close'] = '</li>';
    
            $config['next_tag_open'] = '<li>';
            $config['next_tag_close'] = '</li>';
    
            $config['cur_tag_open'] = '<li class="thisclass">';
            $config['cur_tag_close'] = '</a></li>';
    
            $config['last_tag_open'] = '<li>';
            $config['last_tag_close'] = '</li>';
    
            $config['num_tag_open'] = '<li>';
            $config['num_tag_close'] = '</li>';
    
            $config['page_query_string'] = true;
            $this->pagination->initialize($config);
    
            $data['article'] = $this->article_model->getArticleByPage($current_page, $config['per_page'], $cat_id, $search);
    
            $data['link'] = $this->pagination->create_links();
            return $data;
        }

    如果你想为分页类生成的每个链接添加额外的属性,你可以通过键值对设置 "attributes" 参数:

    $config['attributes'] = array('class' => 'myclass');

  • 相关阅读:
    基于 HTML5 WebGL 构建智能数字化城市 3D 全景
    基于 H5 + WebGL 实现 3D 可视化地铁系统
    基于 HTML5 WebGL 的 3D 科幻风机
    基于 HTML5 + WebGL 的太阳系 3D 展示系统
    HT Vue 集成
    基于 HTML5 + WebGL 的地铁 3D 可视化系统
    基于 HTML5 WebGL 和 VR 技术的 3D 机房数据中心可视化
    String、StringBuffer和StringBuilder的区别
    Python--Numpy基础
    python中的next()以及iter()函数
  • 原文地址:https://www.cnblogs.com/yang-2018/p/12433268.html
Copyright © 2020-2023  润新知