Paginating Search Results - 404 Error |
[eluser]mpar612[/eluser]
It works both ways, with and without index.php. Thanks!
[eluser]TheFuzzy0ne[/eluser]
Oh wait... Sorry, it's just occurred to me what's going on since I've taken the time to actually think about it. CodeIgniter will be looking for a method that matches the page number (which of course you can't have in PHP), so here are my top three solutions: 1) Use _remap() in your controller Code: function _remap() 2) Add a route to redirect all requests for that controller to the index method - $config['basicidx/?(:num'] = "basicidx/index/$1"; (can't vouch for it as I haven't tried it) 3) Call the index method from your URL, followed by the page number - http://www.domain.com/basicidx/index/1 EDIT: You could also do something like this: Code: class Basicidx extends Controller {
[eluser]richwalkup[/eluser]
It's because your pagination links are wrong. The number 5 can not be the name of your controller method so you should be trying to access /basicidx/index/5. Did you set the base_url property? Code: $config['base_url'] = base_url() . 'basicidx/index';
[eluser]mpar612[/eluser]
Thanks TheFuzzy0ne and richwalkup! It still doesn't work. I tried all of the suggestions and the first page of results returns properly, now rather than getting a 404 error after clicking on the pagination links, those links take me to the myform view. Could this have something to do with the form validation in my controller maybe?
[eluser]TheFuzzy0ne[/eluser]
_remap() will work for sure. So long as CodeIgniter can find the controller file, the _remap() method will be called on each request. Please make sure you have removed the route I suggested, and then please post the code you have with the remap method in place.
[eluser]mpar612[/eluser]
Here is my code with the _remap() function included. Thanks! Code: <?php
[eluser]richwalkup[/eluser]
The problem is a core flaw in your logic. Since you are using a parametrized search in order to execute your query, you also have to carry around a couple extra variables well after the initial form post. I have not tested this code obviously but this is closer to what you're looking for. You need to first check for your search parameters being sent as a GET request and then if those don't exist attempt to do the form validation. Code: function index($city='', $price=0) {
[eluser]mpar612[/eluser]
Does anyone have a good tutorial or working example of this? I worked with richwalkup's suggestions and it is still not working properly. Thanks for everyone's help!
[eluser]gtech[/eluser]
[url="http://ellislab.com/forums/viewthread/120038/"]http://ellislab.com/forums/viewthread/120038/[/url] only posted a few hours ago.
[eluser]richwalkup[/eluser]
Had a few issues with the original code but I have actually tested this and it works. Code: function index($city='', $price=0) { |
Welcome Guest, Not a member yet? Register Sign In |