[eluser]luffy[/eluser]
I found that I want to implement the pagination, I have to write much.
So I decide to refactor it.
I build one function below:
Code:
// Pagination
public function pagelist($total, $per_page)
{
$config['base_url'] = base_url().$this->uri->segment(1).'/'.$this->uri->segment(2);
$config['total_rows'] = $total;
$config['per_page'] = $per_page;
$config['first_link'] = 'first';
$config['last_link'] = 'last';
$config['next_link'] = 'next';
$config['prev_link'] = 'previous';
$this->pagination->initialize($config);
return $this->pagination->create_links();
}
And then I put the function in the common model.
If I want to use it, just only need one line below:
$data['page_links'] = $this->common->pagelist($this->say->get_posts_count(), 10);
How do you think that?