controller/index/arg ==> controller/arg? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: controller/index/arg ==> controller/arg? (/showthread.php?tid=8389) Pages:
1
2
|
controller/index/arg ==> controller/arg? - El Forum - 05-16-2008 [eluser]err403_love[/eluser] Is there any way (without routing every URL) to allow CI to default to "controller/argument" if the index() function contains arguments? I don't want to have to set this for every controller in the routes (if you can even change this in routes, that is) and I would find this very useful. Having to use a URL like controller/index/parameter just doesn't make sense. I'm not sure if this is really possible though. If I configured it through routes, it would also try to reroute subdirectories, and I can't have that. I just really wish the URL would be "smart" and figure out that if that URI segment is NOT another function in your controller, and it is NOT a subdirectory, to treat it as an argument of the index() function, if it requires arguments, of course. Thanks. controller/index/arg ==> controller/arg? - El Forum - 05-16-2008 [eluser]nmweb[/eluser] Maybe you can figure something out using _remap() controller/index/arg ==> controller/arg? - El Forum - 05-16-2008 [eluser]Jamie Rumbelow[/eluser] pre-controller hook? controller/index/arg ==> controller/arg? - El Forum - 05-16-2008 [eluser]Pascal Kriete[/eluser] Code: $segments = $this->uri->segment_array(); Change it accordingly if you use folders. edit-add: it would probably be easiest to extend the url helper with a function that does this instead of doing it every time. controller/index/arg ==> controller/arg? - El Forum - 10-08-2008 [eluser]chris613[/eluser] Inparo, I'm not sure I understand your solution. Where would this code go? I've got a search controller that I'd like to be able to call with /search/terms rather than /search/index/terms or (/search/q/terms) Anyone know the way to do this? I could probably brew up a solution with apache url rewriting, but some sort of CI based solution would be more elegant. controller/index/arg ==> controller/arg? - El Forum - 10-08-2008 [eluser]Pascal Kriete[/eluser] I'm not too sure I understand my code either . I would probably do it with a router extension now. For your use case it's easiest with a route, since it's only one controller: Code: $route['search/(.*)'] = 'search/index/$1'; controller/index/arg ==> controller/arg? - El Forum - 10-08-2008 [eluser]chris613[/eluser] Thanks! I've never used routes before, but I think there are a few places on my site that this could be useful. controller/index/arg ==> controller/arg? - El Forum - 10-09-2008 [eluser]Colin Williams[/eluser] _remap() _remap() _remap() controller/index/arg ==> controller/arg? - El Forum - 10-09-2008 [eluser]ray73864[/eluser] what is this _remap() thou speaketh of??? controller/index/arg ==> controller/arg? - El Forum - 10-09-2008 [eluser]Colin Williams[/eluser] If you read through the User Guide, you can't miss it. Check out the page about Controllers. |