0
我的網址有問題。我的分頁工作得很好,但它看起來不那麼好。 例如,我想看到2頁和鏈接變成:localhost/page/9
和第3頁成爲localhost/page/18
我嘗試這個功能:ordonate分頁codeigniter
if($this->uri->segment($config['uri_segment']))
{
$offset = $this->uri->segment($config['uri_segment']);
$segment_to_replace = $this->uri->segment(2);
$new_id = $this->uri->segment(2)/9 +1;
$new_url = str_replace ($segment_to_replace, $new_id, current_url());
redirect($new_url);
}
但代碼不能正常工作。 首先,var_dup($new_url)
return localhost/page/2和redirect($new_url)
return localhost/page/1.222222222。 另一個問題是持續重定向。我怎樣才能使URL顯示curent頁面,而不是我的代碼的偏移量。
完整代碼:
$this->load->library('pagination');
$config['base_url'] = 'http://localhost/page/';
$config['total_rows'] = $this->product_model->count('active');
$config['per_page'] = 9;
$config['num_links'] = 3;
$config['uri_segment'] = 2;
$config['cur_tag_open'] = ' <b>';
$config['prev_link'] = 'Previous';
$config['next_link'] = 'Next';
$this->pagination->initialize($config);
if($this->uri->segment($config['uri_segment']))
{
$offset = $this->uri->segment($config['uri_segment']);
$segment_to_replace = $this->uri->segment(2);
$new_id = $this->uri->segment(2)/9 +1;
$new_url = str_replace ($segment_to_replace, $new_id, current_url());
var_dump($new_url); die;
return redirect($new_url);
}
tnx男人!!你救救我! – RedoColor
乾杯。快樂的編碼。 :) – Tpojka