[solved] Pagination 404 on other pages |
Hello everybody!
![]() I have a question for you ![]() I have created that controller class for my blog: PHP Code: <?php My model: PHP Code: class Blog_m extends CI_Model { My view: PHP Code: <?php foreach($rows as $r) : ?> So, the result view it'OK, i have on http://localhost/codeigniter1/index.php/blog a page with 2 post and at the bottom the paginator with CORRECT LINKS, es: 2 ---- links to --> http://localhost/codeigniter1/index.php/blog/2 3 ---- links to --> http://localhost/codeigniter1/index.php/blog/3 but if i click on it, on the other pages, it returns 404 Page Not Found What I missed ? Thank you so much! ![]()
CodeIgniter is now trying to locate a method called 2 and 3 as your urls are /blog/2 and /blog/3.
Add a detail method to your blog controller for displaying a single blog and change your urls to /blog/detail/2 /blog/detail/3
Sorry,
maybe i have not exlained well. The link to the SINGLE view works perfectly, here i have omitted code for that cause it works, http://localhost/codeigniter1/index.php/blog/view/2 http://localhost/codeigniter1/index.php/blog/view/1 ---> are ok. The probleme is in the PAGINATION LINKS instead, errors are in the pagination links, as http://localhost/codeigniter1/index.php/blog/2 http://localhost/codeigniter1/index.php/blog/3 wich shoul show post dfrom x- to y and from y - to z etc Thank you so much!
Oke, did not get that from your post
![]() You can do one of the following methods 1) Add this to your routes config file located at ./application/config/routes.php PHP Code: $route['blog/(:any)'] = 'blog/index'; 2) You can add the _remap method to your controller PHP Code: public function _remap($method) { If you want to use the _remap method, change your index method to this PHP Code: public function index($page = NULL) { Don't do both ![]()
Ok thanks.
I tied both but there is no way to work, each has a problem. with PHP Code: $route['blog/(:any)'] = 'blog/index'; there is no more the 404 but it doesn'load any other pages than the first one. With the second eaxample doens't works the single view too. So, coudl you please post me an example (just any kind of example) on CI that works? Just a controller and model to create a news section like /news with pagination like /news/1 and single view like /news/view/1 ? So i can study it better. Thank you so much! ![]()
Ok,
I got it. Simply, the uri segment was 2, no 3 or 4! ![]() Thank you so much guys! ![]() |
Welcome Guest, Not a member yet? Register Sign In |