rafi_ccj

Infinite Scroll Controller Function

Jul 25th, 2013
1,157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. function index() {
  2. $this->load->library('pagination');
  3. $this->load->model('menu_model');
  4. $category = '';
  5.  
  6. $data['menu'] = $this->menu_model->get_menu();
  7. $data['count_posts'] = $this->post_model->count_active_posts();
  8.  
  9.  
  10. /* common configuration for pagination */
  11. $config['base_url'] = base_url() . 'home/index';
  12. $config['total_rows'] = $data['count_posts'];
  13.  
  14.  
  15.  
  16. /* Pagination 1st column */
  17. $config['per_page'] = $data['per_page'] = 5;
  18. if ($this->uri->segment(3) > 0) {
  19. $offset = $this->uri->segment(3) * $config['per_page'] - $config['per_page'];
  20. } else {
  21. $offset = $this->uri->segment(3);
  22. }
  23. $config['offset'] = $offset;
  24. $this->pagination->initialize($config);
  25.  
  26. $data['posts'] = $this->post_model->get_first_column($config['per_page'], $config['offset'], $category);
  27.  
  28.  
  29.  
  30.  
  31.  
  32. /* Pagination 2nd column */
  33. $config['per_page'] = $data['per_page'] = 3;
  34. if ($this->uri->segment(3) > 0) {
  35. $offset = $this->uri->segment(3) * $config['per_page'] - $config['per_page'];
  36. } else {
  37. $offset = $this->uri->segment(3);
  38. }
  39. $config['offset'] = $offset;
  40. $this->pagination->initialize($config);
  41.  
  42. $data['all_posts'] = $this->post_model->get_second_column($config['per_page'], $config['offset'], $category);
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49. /* Pagination 3rd column */
  50. $config['per_page'] = $data['per_page'] = 2;
  51. if ($this->uri->segment(3) > 0) {
  52. $offset = $this->uri->segment(3) * $config['per_page'] - $config['per_page'];
  53. } else {
  54. $offset = $this->uri->segment(3);
  55. }
  56. $config['offset'] = $offset;
  57. $this->pagination->initialize($config);
  58.  
  59. $data['new_posts'] = $this->post_model->get_third_column($config['per_page'], $config['offset'], $category);
  60.  
  61.  
  62. $this->load->view('home_view', $data);
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment