Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Codeigniter pagination query string

I want to change codeigniter pagination query string. Currently this is working like below example

http://example.com/1

I want to change this with my example like

http://example.com?page=1

Anyone can let me know how I can do this without changes in existing library? or Should I have to create my own pagination for this system?

Thanks

like image 497
Hira Singh Avatar asked Dec 06 '25 08:12

Hira Singh


2 Answers

You have to set config for pagination

$config['page_query_string'] to TRUE

you also can configure your querystring

$config['query_string_segment'] = 'your_string';
like image 125
John Avatar answered Dec 07 '25 22:12

John


Actually with CodeIgniter 3.0.0 there is a better solution now;

You should enable the reusage of the query string buy enabling this configuration:

$config['reuse_query_string'] = true;

only after that you should initialize the pagination:

$this->pagination->initialize($config);
like image 40
mertyildiran Avatar answered Dec 07 '25 22:12

mertyildiran