[eluser]Unknown[/eluser]
Hi guys,
I'm trying to use the pagination library for my website but I have some problems with it.
Here is my controller code:
Code:
class Projets extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('projets_model', 'projetsManager');
}
public function liste()
{
$this->load->library('pagination');
$per_page = 10;
$total_rows = $this->projetsManager->projets_count();
$offset = $this->uri->segment(3);
$config['base_url'] = site_url('/projets/liste/');
$config['total_rows'] = $total_rows;
$config['per_page'] = $per_page;
$data['categories'] = $this->projetsManager->get_categories();
$data['pagination'] = $this->pagination->create_links();
$data['projets'] = $this->projetsManager->get_all_projets($per_page, $offset);
$this->pagination->initialize($config);
$this->load->view('site/projets_view', $data);
}
}
Here is my model code:
Code:
class Projets_model extends CI_Model
{
protected $table = 'projets';
public function projets_count()
{
return $this->db->count_all($this->table);
}
public function get_all_projets($limit, $offset)
{
$query = $this->db->get($this->table, $limit, $offset);
return $query->result();
}
}
And finaly my view code:
Code:
<?php foreach ($projets as $projet) {
echo $projet->title;
}
?>
<?php echo $pagination?>
So it well displays the 10 first projets title but then I have no pagination links.
Please help me I watched many tutorials and my code seems allright I don't understand what's wrong.