Routes arguments. |
[eluser]Young Caveman[/eluser]
Hi all! First thing first you have to know that I'm a newbie with routes :-) So this is my problem. I set this route: Code: $route[':any'] = "token/section/$1"; This is my controller: Code: function section($section) If I go to http://mysite.some/else the result would be: http://mysite.com/token/section/else But when I pass the variable $section through $data array, the view simply prints "$1". Where's the mistake? :O Thank you all in advance. And, I apologize for my very bad English. :-)
[eluser]Pascal Kriete[/eluser]
Routes are essentially just regular expressions - you need to capture that :any expression, so you can use it in the replacement: Code: $route['(:any)'] = "token/section/$1";
[eluser]Young Caveman[/eluser]
[quote author="inparo" date="1217637286"]Routes are essentially just regular expressions - you need to capture that :any expression, so you can use it in the replacement: Code: $route['(:any)'] = "token/section/$1"; Obviously it works. But as I said I'm just a newbie. :-) Thank you a lot. :-)
[eluser]Scriptor[/eluser]
To expand a bit, $1 is the first set of parentheses, $2 is the second, and so on. |
Welcome Guest, Not a member yet? Register Sign In |