Проблема с пагинацией. как решить?
1
Получилось внести пагинацию в страницу рейтинга, но при перелистывании ничего не изменяется. остаётся всё так как было.
public function rating($slug = NULL) {
$this->load->library('pagination');
$offset = (int) $this->uri->segment(4);
$row_count = 2;
$count = 0;
$count = count($this->films_model->getFilms(0, 1));
$p_config['base_url'] = '/movies/rating/';
$this->data['title'] = "Рейтинг фильмов";
$this->data['movie_data'] = $this->films_model->getMoviesOnPage($row_count, $offset, 1);
if (empty($this->data['movie_data'])) {
show_404();
}
//Pagination config
$p_config['total_rows'] = $count;
$p_config['per_page'] = $row_count;
$p_config['full_tag_open'] = "<ul class='pagination'>";
$p_config['full_tag_close'] = "</ul>";
$p_config['num_tag_open'] = "<li>";
$p_config['num_tag_close'] = "</li>";
$p_config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$p_config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$p_config['next_tag_open'] = "<li>";
$p_config['next_tagl_close'] = "</li>";
$p_config['prev_tag_open'] = "<li>";
$p_config['prev_tagl_close'] = "</li>";
$p_config['first_tag_open'] = "<li>";
$p_config['first_tagl_close'] = "</li>";
$p_config['last_tag_open'] = "<li>";
$p_config['last_tagl_close'] = "</li>";
//init pagination
$this->pagination->initialize($p_config);
$this->data['pagination'] = $this->pagination->create_links();
$this->load->view('templates/header', $this->data);
$this->load->view('movies/rating', $this->data);
$this->load->view('templates/footer');
}
1 ответов
1
У меня так выглядит пагинация в рейтинге - работает:
public function rating() {
$this->data['title'] = "Рейтинг фильмов";
$this->load->library('pagination'); //pagination
$offset = (int) $this->uri->segment(2); //pagination
$row_count = 5; //pagination
$count = count($this->Films_model->getMoviesOnPageByRating(0, 0)); //pagination
$p_config['base_url'] = '/rating/'; //pagination
$this->data['movie'] = $this->Films_model->getMoviesOnPageByRating($row_count, $offset); //pagination
//pagination config
$p_config['total_rows'] = $count;
$p_config['per_page'] = $row_count;
//pagination bootstrap
$p_config['full_tag_open'] = "<ul class='pagination'>";
$p_config['full_tag_close'] ="</ul>";
$p_config['num_tag_open'] = '<li>';
$p_config['num_tag_close'] = '</li>';
$p_config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$p_config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$p_config['next_tag_open'] = "<li>";
$p_config['next_tagl_close'] = "</li>";
$p_config['prev_tag_open'] = "<li>";
$p_config['prev_tagl_close'] = "</li>";
$p_config['first_tag_open'] = "<li>";
$p_config['first_tagl_close'] = "</li>";
$p_config['last_tag_open'] = "<li>";
$p_config['last_tagl_close'] = "</li>";
//init pagination
$this->pagination->initialize($p_config);
$this->data['pagination'] = $this->pagination->create_links();
$this->load->view('templates/header', $this->data);
$this->load->view('main/rating', $this->data);
$this->load->view('templates/footer');
}