У меня проблема с разбиением на страницы в кодеигниторе. Когда я применяю фильтры для уменьшения набора записей, разбиение на страницы, похоже, кажется, что оно по-прежнему связано с нефильтрованными данными. Так, например, хотя в возвращенном наборе данных есть только одна страница данных, отображаются еще 3 ссылки на страницы. Нажатие на другое, кроме первого, вернет пустую страницу.codeigniter pagination не работает с применяемыми фильтрами
Вот мой код контроллера
function pro_client_list() {
//called to open the List tab of the pro_clients_view
$this->load->library('pagination');
//this version is for localhost
$config['base_url'] = '/index.php/main_controller/pro_client_list/';
$config['total_rows'] = $this->pro_client_model->count_clients();;
$config['per_page'] = 20;
$config['full_tag_open'] = '<div class="pagination"><ul>';
$config['full_tag_close'] = '</ul></div>';
$this->pagination->initialize($config);
$data = array();
// DEV-140905A - check the state of the filters and only load matching clients
$this->load->model('filter_model');
$this->load->model('pro_client_model');
$c_filter = $this->filter_model->get_client_category_filter();
$y_filter = $this->filter_model->get_client_country_filter();
$data['clients'] = $this->pro_client_model->get_clients($config['per_page'], $this->uri->segment(3), $c_filter, $y_filter);
$this->load->model('filter_model');
$data['categories'] = $this->filter_model->get_unique_categories();
$data['countries'] = $this->filter_model->get_unique_countries();
$this->load->view('includes/header');
$this->load->view('pro_client_list', $data);
$this->load->view('includes/footer');
}
и это код модели
function get_clients($num, $offset, $c_filter, $y_filter) {
/*
Returns a list of all clients in the database with pagination pointers
Modified to return a count of the contacts belonging to each client 04/09/2014
*/
$this->c_filter = $c_filter;
$this->y_filter = $y_filter;
$this->db->order_by("vch_name", "asc");
$this->db->select('*,
(SELECT COUNT(*) FROM tbl_contact WHERE fk_client_id=tbl_pro_client_id) AS count_contacts,
(SELECT MIN(vch_next_interact) FROM tbl_contact WHERE fk_client_id=tbl_pro_client_id) AS next_interact'
, false);
if($c_filter != '-1') {
$this->db->where('vch_category', $this->c_filter);
}
if($y_filter != '-1') {
$this->db->where('vch_country', $this->y_filter);
}
$query = $this->db->get('tbl_pro_client', $num, $offset);
return $query;
}
Пожалуйста, не то, что нумерация страниц работает нормально, перед добавлением Категория и Country фильтры.
Любая помощь очень ценится,
U.