Routing a controller - how to dismiss certain functions? - 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: Routing a controller - how to dismiss certain functions? (/showthread.php?tid=18253) |
Routing a controller - how to dismiss certain functions? - El Forum - 04-30-2009 [eluser]loathsome[/eluser] Hello, I'm currently developing an application, and for this I have a signup-controller. As a first parameter in the index function I have a variable whose purpose is to receive a language code and process it later on. (En, Gb, etc) Code: class Signup extends Peeps_Controller { Now, I want to route everything that goes to app/signup to app/signup/index/$1 - EXCEPT "post" and "quick", those should go to app/signup/post - because those are their own functions. I do not want to create another route, but rather do it all in the same using regex - I'm almost there. I've tried Code: $route['signup/((.*)|^post|^quick)'] = "signup/index/$1"; app/signup/whatever should go to app/signup/index/whatever app/signup/post OR quick should go to app/signup/post OR quick Routing a controller - how to dismiss certain functions? - El Forum - 04-30-2009 [eluser]Dam1an[/eluser] Do you need to explicity say 'anything or not post or not quick'? Would it not be sufficient for just the (^post|^quick) part? I may be totally wrong, as I've only used positive matching in my routes Routing a controller - how to dismiss certain functions? - El Forum - 04-30-2009 [eluser]xwero[/eluser] Code: $route['(signup/)(?!post|quick)'] = '$1$2'; // i fetch the controller too because i'm lazy If that doesn't work you can always do Code: $route['(signup/)(post|quick)'] = '$1$2'; Routing a controller - how to dismiss certain functions? - El Forum - 04-30-2009 [eluser]Dam1an[/eluser] Do you not need to do the variables on the right of the expression in double quotes? Otherwise PHP won't parse the values of the $1 and $2? Cause thats the normal case with strings in PHP Routing a controller - how to dismiss certain functions? - El Forum - 04-30-2009 [eluser]xwero[/eluser] double or single quotes don't matter, it's processed internally. You can't even have a variable name that only has digits as a name. Routing a controller - how to dismiss certain functions? - El Forum - 04-30-2009 [eluser]Dam1an[/eluser] I figured that the $1, $2 etc where just placeholders, and would be replaced with the args (bit like in C), but assumed it would need to be double quotes to be processed, just like strings... I learn something new every day |