Route into a controller sub-directory |
[eluser]Edemilson Lima[/eluser]
I am having a problem with a routing... At my routes.php, I have: Code: $route['([a-z]+)/([0-9]+)'] = "$1/details/index/$2"; If I go to: http://www.site.com/products/details/index/3 It works fine. But, if I do it by the route: http://www.site.com/products/3 It calls products/details/index, but does not send the id code: Code: A PHP Error was encountered "products" is a folder, "details" is the controller and "index" is its default function.
[eluser]wiredesignz[/eluser]
after a lot of testing I found this route works instead oddly enough: Code: $route['([a-z]+)/([0-9]+)'] = '$1/details/index/$0'; Can someone explain or do a check on this please. TIA
[eluser]xwero[/eluser]
is Code: $route['([a-z]+)/([0-9]+)'] = "$1/details/$2";
[eluser]Edemilson Lima[/eluser]
No. This was my first try. It returns a 404 page.
[eluser]Edemilson Lima[/eluser]
Code: $route['([a-z]+)/([0-9]+)'] = '$1/details/index/$0'; This worked for me too! Well, I will use it until another solution be provided.
[eluser]Derek Jones[/eluser]
Some threads are coming close to crossing one another here, but to be thorough, try updating from the SVN, as a related bug was fixed yesterday.
[eluser]Edemilson Lima[/eluser]
No problem, I will wait for the next CI release. =) My first CI-based project is in the beginning anyway.
[eluser]wiredesignz[/eluser]
Well you didn't have to wait too long after all.
[eluser]sophistry[/eluser]
I grabbed the 1.6 release from the download page today (20080131) and I am seeing these same bugs when using regex routing (my controller is not in sub-dirs): http://ellislab.com/forums/viewthread/48779 http://ellislab.com/forums/viewthread/50795/ to sum up... regex routes set segments properly but don't send them as controller parameters properly. so, when i put a regex route like this: Code: $route['[a-z]{3}'] = "welcome/index/$1"; the parameter sent to the controller function is the literal string dollarsign1 ($1). I also tried $0 and that did the same thing. but, the segment_array() method shows the right data - it has the string captured by the regex. i checked the bug forum and this was the latest talk about it. is this expected behavior? should i just use the $this->uri->segment(n) method and be done?
[eluser]Edemilson Lima[/eluser]
Did you try the expression inside parenthesis? Code: $route['([a-z]{3})'] = "welcome/index/$1"; Aren't the parenthesis that determine what will become $1, $2, $3, etc? |
Welcome Guest, Not a member yet? Register Sign In |