CodeIgniter
CodeIgniter copied to clipboard
how should i get the current page when use CI_Pagination library .
$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?
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
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);