class Post extends CI_Controller{
public function __construct() {
parent::__construct();
}
public function all_posts()
{
$this->load->library('pagination');
$offset = 0;
//per_page is the variable of pagination library, if you want you can change this variable name in pagination configs
if ($this->input->get('per_page') != null) {
$offset = $this->input->get('per_page');
}
$count = 10; //number of posts in page
filter = array();
$data['post_count'] = $this->post_model->get_total_post_count($filter); //pagination need to know how many total posts you have
$data['posts'] = $this->post_model->get_posts($filter, $limit, $offset);
$config['base_url'] = site_url() . 'post/all_posts';
$config['total_rows'] = $data['post_count'];
$config['per_page'] = $count;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->load->view('templates/header', $data);
}