0
votes

I have config code for Codeigniter's pagination

$config['base_url']   = $base_url;
$config['total_rows'] = $total_search_results;
$config['per_page']   = $per_page;
$config['num_links']        = 4;
$config['use_page_numbers'] = FALSE;
$config['page_query_string'] = TRUE;
$config['query_string_segment'] = 'limit-offset';

I have "limit" and "limit-offset" values that are gotten from GET query strings which is where I derive the $per_page value.

However, in the pagination links that are produced, I still want to include the "limit" and "limit-offset" values in a url like

www.domain.com/test/?limit=10&limit-offset=20

How do we do these using Codeigniter Pagination library?

2

2 Answers

0
votes

Refer to @WesleyMurch's answer here at Pagnation with GET data in the uri - Codeigniter

// After loading the pagination class
$this->pagination->suffix = '{YOUR QUERY STRING}';

Or better yet, just add $config['suffix'] = '{YOUR QUERY STRING}'; to your config before loading the class.

0
votes

You must edit your

config["base_url"] = www.domain.com/test?limit=xxx;

edit

config['per_page'] = $this->input->get("limit");

This is the complete config :

//your base url : www.domain.com/
$config['base_url']   = sprintf("%stest/?limit=%d", $base_url, $this->input->get("limit")); // it will generate : www.domain.com/test?limit=xxx
$config['total_rows'] = $total_search_results;
$config['per_page']   = $this->input->get("limit");
$config['num_links']        = 4;
$config['use_page_numbers'] = FALSE;
$config['page_query_string'] = TRUE;
$config['query_string_segment'] = 'limit-offset';

Then, foreach pagination link will have this format : www.domain.com/test/?limit=10&limit-offset=20