Class and Function URI segments redundant - how to work around them? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Class and Function URI segments redundant - how to work around them? (/showthread.php?tid=8993) |
Class and Function URI segments redundant - how to work around them? - El Forum - 06-07-2008 [eluser]Aquillyne[/eluser] There are plenty of occasions when I don't actually need to specify my class and function, but I am forced to. Is there a way to get straight into the "id" part, i.e. the part that is passed as a parameter? For instance, I want a welcome controller that does nothing more than output something from the URI. I want to go to mysite.com/<foo> and see <foo> on the page - that's it. Without CI this is ridiculously easy. The index.php file just echoes what's in the $_GET. A .htaccess file, as with CI, reduces mysite.com/index.php?=foo back to mysite.com/foo. Easy. But how to do this with CI? A similar case. A function in my welcome controller accepts a parameter. Why must I go to mysite.com/welcome/function/param rather than just mysite.com/function/param, when the "welcome" has been implicit all along? This is basically the same question as before: why do I have to specify mysite.com/welcome/index/param rather than just mysite.com/param when the "welcome" and "index" were previously implicit? Note that I only want this to happen on particular pages, which is again very easy without CI. My "foods" page may have no further functions, and hence just immediately accept a parameter. I can use mysite.com/foods.php?=param, or mysite.com/foods/param to do this. But in CI, the foods/param is assumed to refer to a function "param" in the "foods" class. How do I specify, only on the "foods" page, that the second URI segment is to be passed as a parameter? Is there a way to work around this? Thanks for any help. Class and Function URI segments redundant - how to work around them? - El Forum - 06-07-2008 [eluser]Michael Wales[/eluser] URI Routing |