Reputation: 261
i am doing pagiation with codeigniter, its showing all the pagination link like
But i just want to show something like 1 2 3 Next. My code is
$start_index = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$total_reports = $data['losts'];
$this->load->library('pagination');
$config['base_url'] = base_url().'Lost/list';
$config['total_rows'] = count($data['losts']);
$config['per_page'] = 10;
$config['use_page_numbers'] = TRUE;
$config['num_links'] = count($data['losts']);
// Open tag for CURRENT link.
$config['cur_tag_open'] = ' <a class="current">';
// Close tag for CURRENT link.
$config['cur_tag_close'] = '</a>';
// By clicking on performing NEXT pagination.
$config['next_link'] = 'Next';
// By clicking on performing PREVIOUS pagination.
$config['prev_link'] = 'Previous';
$this->pagination->initialize($config);
$str_links = $this->pagination->create_links();
$data["links"] = explode(' ',$str_links );
Thanks in advance.
Upvotes: 1
Views: 83
Reputation: 1633
You are setting $config['num_links']
with total numbers of rows.
But you need to set it to number of links to be generated.
$config['num_links'] = 3;
The number of “digit” links you would like before and after the selected page number. For example, the number 2 will place two digits on either side, as in the example links at the very top of this page.
Reference : https://www.codeigniter.com/userguide3/libraries/pagination.html#customizing-the-pagination
Upvotes: 1