Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function index() {
- $this->load->library('pagination');
- $this->load->model('menu_model');
- $category = '';
- $data['menu'] = $this->menu_model->get_menu();
- $data['count_posts'] = $this->post_model->count_active_posts();
- /* common configuration for pagination */
- $config['base_url'] = base_url() . 'home/index';
- $config['total_rows'] = $data['count_posts'];
- /* Pagination 1st column */
- $config['per_page'] = $data['per_page'] = 5;
- if ($this->uri->segment(3) > 0) {
- $offset = $this->uri->segment(3) * $config['per_page'] - $config['per_page'];
- } else {
- $offset = $this->uri->segment(3);
- }
- $config['offset'] = $offset;
- $this->pagination->initialize($config);
- $data['posts'] = $this->post_model->get_first_column($config['per_page'], $config['offset'], $category);
- /* Pagination 2nd column */
- $config['per_page'] = $data['per_page'] = 3;
- if ($this->uri->segment(3) > 0) {
- $offset = $this->uri->segment(3) * $config['per_page'] - $config['per_page'];
- } else {
- $offset = $this->uri->segment(3);
- }
- $config['offset'] = $offset;
- $this->pagination->initialize($config);
- $data['all_posts'] = $this->post_model->get_second_column($config['per_page'], $config['offset'], $category);
- /* Pagination 3rd column */
- $config['per_page'] = $data['per_page'] = 2;
- if ($this->uri->segment(3) > 0) {
- $offset = $this->uri->segment(3) * $config['per_page'] - $config['per_page'];
- } else {
- $offset = $this->uri->segment(3);
- }
- $config['offset'] = $offset;
- $this->pagination->initialize($config);
- $data['new_posts'] = $this->post_model->get_third_column($config['per_page'], $config['offset'], $category);
- $this->load->view('home_view', $data);
- }
Advertisement
Add Comment
Please, Sign In to add comment