Advertisement
VladimirsBudkins

CI pagination

Oct 13th, 2015
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. $this->load->library('pagination');
  2. $this->load->model('model');
  3. $this->config->load('pagination');
  4. $def_config = $this->config->item('pagination');
  5. $pagination_uri_segment = $this->uri->rsegment(3);
  6. $config = array_merge($def_config , [
  7.     'base_url' => base_url($this->router->class . '/' . $this->router->method),
  8.     'total_rows' => $this->model->count_all(),
  9.     'uri_segment' => $pagination_uri_segment,
  10.     'per_page' => 20,
  11. ]);
  12. $this->pagination->initialize($config);
  13. $this->load->view('view',[
  14.     'pagination_links'=> $this->pagination->create_links(),
  15.     'records'=> $this->model->find_all([
  16.         'limit'=> $config['per_page'],
  17.         'offest'=> $config['uri_segment'],
  18.     ]),
  19. ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement