CodeIgniter icon indicating copy to clipboard operation
CodeIgniter copied to clipboard

how should i get the current page when use CI_Pagination library .

Open singleseeker opened this issue 13 years ago • 2 comments

$config['page_query_string'] = TRUE;

CI_Pagination library is good, but here i have a question about this. i config my lib like this.

if i have 50 pages. when i visit xxx.com/show?page=100 ci will show the last page(page 50)

but how should i get this page number. is this possible to use $this->pagination->cur_page; to get the number?

any ideas?

singleseeker avatar Jun 01 '13 07:06 singleseeker

You could do what you suggest.

I googled this problem and the first thing that popped up was this http://leaveurdream.blogspot.nl/2010/09/get-current-page-from-codeigniter.html

marcvdm avatar Jun 01 '13 23:06 marcvdm

here is my solution.

change the pagination lib cur_page,per_page from protected to public.

controllers

$this->data["all_article"] = $this->mdl_article_auth->get_all_article();

$config['base_url'] = site_url("manage/article");
$config['total_rows'] = count($this->data["all_article"]);
$config['per_page'] = 10;

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

$this->data['pagination'] = $this->pagination->create_links();

$this->data["show_article"] = $this->mdl_article_auth->get_show_article($this->pagination->cur_page,$this->pagination->per_page);


singleseeker avatar Jun 02 '13 22:06 singleseeker