我有Codeigniter的分页配置代码
$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';
我有从GET查询字符串获取的“limit”和“limit-offset”值,这是我获取$ per_page值的地方。
但是,在生成的分页链接中,我仍然希望在URL中包含“limit”和“limit-offset”值,如
www.domain.com/test/?limit=10&limit-offset=20
我们如何使用Codeigniter Pagination库进行这些操作?
答案 0 :(得分:0)
请参阅Pagnation with GET data in the uri - Codeigniter
上的@WesleyMurch答案// After loading the pagination class
$this->pagination->suffix = '{YOUR QUERY STRING}';
或者更好的是,只需在加载课程之前将$config['suffix'] = '{YOUR QUERY STRING}';
添加到您的配置中。
答案 1 :(得分:0)
您必须编辑
config["base_url"] = www.domain.com/test?limit=xxx;
编辑
config['per_page'] = $this->input->get("limit");
这是完整的配置:
//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';
然后,foreach分页链接将具有以下格式: www.domain.com/test/?limit=10&limit-offset=20