zoukankan      html  css  js  c++  java
  • 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');

  • 相关阅读:
    C# 发送匿名邮件
    上传大文件,Web.config中的配置
    老话题关于文章自动分页
    scrollLeft,scrollWidth,clientWidth,offsetWidth到底指的哪到哪的距离
    转成静态页面,由于ie网址或路径原因,Atlas失效。
    让图片自适应大小的方法
    textoverflow 全兼容
    ISAPI_rewrite中文手册
    ISAPI_Rewrite集
    无限级下拉列表框控件
  • 原文地址:https://www.cnblogs.com/yang-2018/p/12433268.html
Copyright © 2011-2022 走看看