CodeIgniter Forums

Full Version: pagination problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm using codeigniter 3 and using hmvc for admin but problem pagination no showing First a Last link.i could not understand where is the problem.Is it ci3 problem or my script problem

$config['per_page'] = 2;
$config['base_url'] = base_url().'admin/manage-cms';
$config['num_links'] = 20;
$config['uri_segment'] = 3;
$page = $this->uri->segment(3);
$limit_end = ($page * $config['per_page']) - $config['per_page'];
if ($limit_end < 0){
$limit_end = 0;
}
$config['first_link'] = 'First';
$config['last_link'] = 'Last';

$data['count_cms']= $this->cms_model->count_cms();
$config['total_rows'] = $data['count_cms'];
$data['cms'] = $this->cms_model->get_cms($config['per_page'],$limit_end);

$this->pagination->initialize($config);

i also updated the code to

$config['per_page'] = 2;
$config['base_url'] = base_url('admin/manage-cms');
$config['num_links'] = 20;
$config['uri_segment'] = 3;
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$config['first_link'] = 'First';
$config['last_link'] = 'Last';
$data['count_cms']= $this->cms_model->count_cms();
$config['total_rows'] = $data['count_cms'];
$data['cms'] = $this->cms_model->get_cms($config['per_page'],$page);
$this->pagination->initialize($config);


But following problem have found

1)in url, pagination coming like url/2,url/4,url/6 etc But i trying to show url/1,url/2,url/3
2) I have inserted 9 records in db but still First and Last link is not displayed
(08-17-2015, 11:07 AM)avijit.nanda07 Wrote: [ -> ]But following problem have found

1)in url, pagination coming like url/2,url/4,url/6 etc But i trying to show url/1,url/2,url/3
2) I have inserted 9 records in db but still First and Last link is not displayed

http://www.codeigniter.com/user_guide/li...pagination

1) $config['use_page_numbers'] = TRUE;
2) Try setting $config['num_links'] to a lower number (like 2), at least to test and make sure the links will show up. You need at least one or two more pages than num_links will display before you get a first/last link, and you won't get a first link on the first page (or last link on the last page).