Reputation: 11907
I have got a problem. $this->pagination->create_links()
returns null
string.
Here is model :
class Pagination_m extends CI_Model {
public function PaginationHome($count)
{
$this->load->library('pagination');
$config['base_url'] = base_url().'home';
$config['total_rows'] = ceil($count/12);
$config['per_page'] = 5;
$config['uri_segment'] = 2;
$config['full_tag_open'] = '<div style="float: left; width: 960px;">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
}
}
Controller:
$count = count($this->pictures_m->getAll());
$this->load->model('pagination_m');
$this->pagination_m->PaginationHome($count);
$data['links'] = $this->pagination->create_links();
var_dump($data['links']);
$count
returns 15,
Thanks!
Upvotes: 0
Views: 7040
Reputation: 13728
keep your pagination config in your controller would be:-
$this->load->library('pagination');
$per_page = 50;
$data['result'] = $this->model->function_name(); // for display result
$config['total_rows'] = $this->model->function_name(); // or count rows
$config['per_page']= $per_page;
$config['uri_segment'] = 3;
$config['base_url']= base_url().'/index'; // your url
$config['suffix'] = '?'.http_build_query($_GET, '', "&");
$this->pagination->initialize($config);
$data['paginglinks'] = $this->pagination->create_links();
$this->load->view('viewname', $data); //your view name
Model:-
write function which return bunch of data and count rows
view (display your data):-
<?php echo $paginglinks; ?>
For more :- http://ellislab.com/codeigniter/user-guide/libraries/pagination.html
Upvotes: 1