how do i show the page numbers in GET format with ? in codeigniter

The Rahul Jha :

I am having a difficulty which I think must have a very simple answer. i am using CodeIgniter for my project and I am using the pagination to show page numbers for posts

CODE

$this->load->library('pagination');
        if (count($_GET) > 0) $config['suffix'] = '?' . http_build_query($_GET, '', "&");
        $config['base_url'] = base_url('index.php/main/bloggers');
        $config['total_rows'] = $total_num;
        $config['per_page'] = $rec_per_page;
        $config['num_links'] = 10;
        $config['use_page_numbers'] = TRUE;
        $config['reuse_query_string'] = false;
        $config['full_tag_open'] = "<span class='page_num'>";
        $config['full_tag_close'] = '</span>';
        $this->pagination->initialize($config);

This code shows me the url like this

domain.com/index.php/main/blogger/**2**

where 2 is the page number which is good

current url is like this

domain.com/index.php/main/blogger/**2**

Desired url is

domain.com/index.php/main/blogger?**page=2**

Question: what I want is that I want the page number to come in GET type of variable so that I can just use GET and get the value of page as if I use segment I am not sure there may be other values too some times.

Any help is appreciated.

Jeemusu :

You need to set the following options on your pagination configuration array:

// Set the pagination to use the get parameter
$config['page_query_string'] = TRUE;

// Set the name of the get paramater
$config['query_string_segment'] = 'page';

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=11940&siteId=1