我在使用 Codeigniters 分页类时遇到了一些问题。
问题是“第 1 页”仍然是粗体,即使 URL 发生了变化。
我的网址如下所示:
http://mypage.com/s/search+str/4/1
uri->segment(3) 是 per_page,uri->segment(4) 是页码。
我已经设置了 $config['uri_segment'] = 4; 正如您在下面的代码中看到的那样。
任何人都可能看到代码有什么问题?
谢谢..
/** Load The Search model **/
$this->load->model('search_model');
/** Perform the search **/
$this->search_model->set_search_str(decode_url($str));
// prettyPrint($config['per_page']); die();
$offset = $this->uri->segment(4,0);
/** Pagination **/
$this->load->library('pagination');
$config = array (
'uri_segmet' => 4,
'per_page' => $this->uri->segment(3, 25),
'total_rows' => $this->search_model->get_nums(),
'num_links' => 4,
'base_url' => base_url()."s/{$str}/".$this->uri->segment(3, 25),
'use_page_numbers' => TRUE
);
$this->pagination->initialize($config);
$pagination_links = $this->pagination->create_links();
$query = $this->search_model->search( $config['per_page'], $offset );
$num_results = $this->search_model->get_nums();
/** Set the theme data **/
$data = array(
'title' => 'Search page',
'page' => 'search',
's_str' => decode_url($str),
'num_results' => $num_results,
'results' => $query['results'][0],
'pagination' => $pagination_links
);
/** Load the theme **/
$this->load->theme($data);