我正在使用CI分页课程。
当我在与第1页不同的任何页面上(使用过滤)时,我的网址将如下所示:
http://localhost/codeigniter/search/interests=5%2C23%2C12%2C13&fulldate=&location=/2
在第1页上,它会告诉我:
http://localhost/codeigniter/search/
过滤仍然可以,所以它只是隐藏了查询字符串和页码。
我注意到当我转到第2页时,请返回第1页,该网址是正确的。
我需要第一页上的网址也是这样的:
http://localhost/codeigniter/search/interests=5%2C23%2C12%2C13&fulldate=&location=/1
控制器功能的相关部分如下所示:
$this->load->library('pagination');
$data['all_vacancies'] = $this->vacancies_model->getFilteredVacanciesOverview($filterdata);
if(!array_filter($filterdata)) {
$pagconfig['base_url'] = base_url().VACANCY_OVERVIEW;
} else {
$pagconfig['base_url'] = base_url().VACANCY_OVERVIEW . http_build_query($filterdata);
}
$pagconfig['first_url'] = '1';
$pagconfig['total_rows'] = count($data['all_vacancies']);
$pagconfig['per_page'] = 3;
if (LOCATION) {
if (is_numeric($this->uri->segment(3))) {
$pagconfig['uri_segment'] = 3;
} else {
$pagconfig['uri_segment'] = 4;
}
} else {
if (is_numeric($this->uri->segment(2))) {
$pagconfig['uri_segment'] = 2;
} else {
$pagconfig['uri_segment'] = 3;
}
}
$pagconfig['use_page_numbers'] = TRUE;
$this->pagination->initialize($pagconfig);
$data['links'] = $this->pagination->create_links();
导航菜单中的链接如下所示:
<a href="<?=site_url('vrijwilligerswerk/', $link_protocol )?>" class="nav-link">
<span><?=lang("nav_dashboard_vacancy_overview")?></span>
</a>
我的routes.php文件如下所示:
$route['^vrijwilligerswerk'] = 'dashboard/vacancy/overviewVacancies';
$route['^vrijwilligerswerk/(:num)'] = 'dashboard/vacancy/overviewVacancies/null/null/$1';
$route['^vrijwilligerswerk/(:any)'] = 'dashboard/vacancy/overviewVacancies/null/$1';
$route['^vrijwilligerswerk/(:any)/(:num)'] = 'dashboard/vacancy/overviewVacancies/null/$1/$2';
我尝试使用不同主题的答案,例如:
$pagconfig['first_url'] = '1';
或在Pagination类文件中将以下内容设为true:
protected $reuse_query_string = TRUE;
但这些都没有显示第1页的查询字符串