1
我不知道我要問什麼是可能的或沒有..我想可能不是,但我想我會問無論如何。代碼點火器分頁與排序選項
有什麼方法可以重置分頁?
我有一個頁面上有分頁和排序選項。一切工作正常,但當排序選項之一更改,我想發送用戶回到第一頁。
(我敢肯定,我這樣做的方式是不是在所有,如果您有任何改進建議,請隨時得到我想要這樣的結果的最佳方式。)
$array = explode ("_",$this->uri->segment(4));
if(count($array) > 1){
$search_id = $array[1];
$start = $this->uri->segment(5);
$uri_segment = 5;
}else{
$start = $this->uri->segment(4);
$uri_segment = 4;
$search_id = null;
}
$config['per_page'] = $this->settings['PRODUCTS_PER_PAGE'];
$config['total_rows'] = $this->categories_model->get_num_rows($cat_id , $search_type, $search_data);
$query = $this->categories_model->get_category_pages($cat_id, $new_limit, $new_sort, $search_id, $start, $this->settings['CATEGORY_ORDER'], $search_type, $search_data, $config['total_rows']))
$config['base_url'] = base_url() . 'index.php/categories/view/' . $cat_id ."/" . $search_string ;
$config['uri_segment'] = $uri_segment;
//Congig settings for pagination
$config['full_tag_open'] = '<div id="pagination" style= "clear:both;">';
$config['full_tag_close'] = '</div>';
//Initialise pagination
$this->pagination->initialize($config);
您使用一個表來在頁面上顯示的數據? – Shivaas
不,我不是我只是循環瀏覽每個結果並將它們回顯到頁面。 – flyersun
我建議在一個表格中顯示數據(使用css樣式,它甚至不會像最終用戶的表格一樣!),然後利用jQuery dataTables插件進行排序,搜索和分頁。該插件支持服務器端分頁,因此您的代碼在某種程度上仍然可以重用。 – Shivaas