我遇到了Codeigniters分页类的一些问题。Codigniter分页 - 第一页保持大胆
问题是,即使URL中的更改,“页面1”仍然为粗体。
我的网址是这样的:
http://mypage.com/s/search+str/4/1
URI->段(3)是per_page和URI->段(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);
刚刚尝试过..但它似乎不工作?我无法理解它。我试图做第四个uri段的print_r,后面跟着一个die();它确实得到正确的价值?这对我来说似乎很奇怪。它可以和我的base_url有什么关系吗? – Thomas 2012-04-22 08:19:44
我有点斋戒!我尝试将'current_page'作为分页类中变量的名称'cur_page',现在它可以工作!奇怪,我必须告诉它我在哪里:)谢谢! – Thomas 2012-04-22 08:21:53