Pagination , Routing 404 - Newbie |
Learning CI3 ..... building a simple cms . Added ' pagination' to the libraries array and tried the code below
In the posts controller index function i am showing all my posts ( Total of 7 posts of which i try to show 5) . When i try to use pagination it is showing 404 error ie; http://localhost/CI3/posts - shows all 7 posts with pagination links in bottom , clicking '2' takes to http://localhost/CI3/posts/5 which is giving a 404 page not found . route.php ------------ PHP Code: $route['posts/create'] = 'posts/create'; Posts.php ------------ PHP Code: Class Posts extends CI_Controller { Can somebody help with what went wrong ..
$route ['posts/(:any)' ] = 'posts/view/$1' ;
This route find single post. In your pagination, '/post/{page}' will find post using page param not navigate to other pages and I'm sure in your Post controller searching for invalid post will show 404 page. Btw at the bottom of route, $route ['(:any)' ] = 'pages/view/$1' ; also for viewing single post.
Keep calm.
Also the default controller cannot be within a sub-directory.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(04-29-2017, 02:17 AM)arma7x Wrote: $route ['posts/(:any)' ] = 'posts/view/$1' ; Thank you for the reply , but as a newbie i just tried removing that route , but still the pagination is not working for me . Can you please let me know how to make the pagination work ?
No it would be your default page shown when someone visits your site like home, welcome or splash page.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |