CodeIgniter Forums
Pagination on homepage - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forum-11.html)
+--- Thread: Pagination on homepage (/thread-69452.html)



Pagination on homepage - phoenix9080 - 11-25-2017

Hi

I'm trying to have pagination on index of my default controller.
e.g. http://domain.com/

i'm getting 404 error when going to second page on pagination
e.g http://domain.com/2

i understand it is looking for a controller as 2nd uri segment, hence 404 error.

Any idea how to solve the problem?

Thanks in advance.


RE: Pagination on homepage - skunkbad - 11-25-2017

Something like this in a Welcome controller:
Code:
public function index(){
   $this->page();
}

public function page( $page = 1 ){
   echo 'You are on page ' . $page;
}

Then in routes something like:


Code:
$route['(:num)'] = 'welcome/page/$1';



RE: Pagination on homepage - phoenix9080 - 12-04-2017

(11-25-2017, 11:13 PM)skunkbad Wrote: Something like this in a Welcome controller:
Code:
public function index(){
  $this->page();
}

public function page( $page = 1 ){
  echo 'You are on page ' . $page;
}

Then in routes something like:


Code:
$route['(:num)'] = 'welcome/page/$1';

Thank you. This helped 100%.