如何在Codigniter中添加这种类型的分页(http://my-url.com/search?qry=abc&page=2)

时间:2016-03-28 17:15:32

标签: codeigniter pagination

currently i am using this code for pagination in Codigniter 
$config['base_url']          =   SITEURL. 'search?qry='.$qry.'&';
            $config['use_page_numbers']  = TRUE;
            $config['full_tag_open']     = '<ul class="pagination">';
            $config['full_tag_close']    = '</ul>';
            $config['first_link']        = false;
            $config['last_link']         = false;
            $config['first_tag_open']    = '<li>';
            $config['first_tag_close']   = '</li>';
            $config['prev_link']         = '&laquo';
            $config['prev_tag_open']     = '<li class="prev">';
            $config['prev_tag_close']    = '</li>';
            $config['next_link']         = '&raquo';
            $config['next_tag_open']     = '<li>';
            $config['next_tag_close']    = '</li>';
            $config['last_tag_open']     = '<li>';
            $config['last_tag_close']    = '</li>';
            $config['cur_tag_open']      = '<li class="active"><a href="#">';
            $config['cur_tag_close']     = '</a></li>';
            $config['num_tag_open']      = '<li>';
            $config['num_tag_close']     = '</li>';
            $config['total_rows']        = $total_rows;
            $config['per_page']          = RECORD_PER_PAGE;
            $config['first_url']         = $config['base_url'] . '1' . http_build_query($_GET);
            $config['num_links']         = 5;

从我看到的,CodeIgniter的分页是错误地计算页面。因为我希望分页看起来像这样:

http://my-url.com/search?qry=abc&page=2

1 个答案:

答案 0 :(得分:0)

如果您不想使用CI提供的noraml uri字符串,并且您想使用查询字符串(site.com?var1=data&var2=xxx)

您需要更改设置行

的application / config / config.php文件
158 $config['enable_query_strings'] = FALSE; to TRUE

在你的控制器中使分页使用普通形式获取变量

$var1 = $this->input->get('c');
$var2 = $this->input->get('m');
$var3 = $this->input->get('d');