Welcome Guest, Not a member yet? Register   Sign In
Routes arguments.
#1

[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";
Which takes to the controller "token" and passes to the function "section" the argument "any".
This is my controller:
Code:
function section($section)
{
    stuff
}

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. :-)
#2

[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";
#3

[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";
[/quote]
Obviously it works. But as I said I'm just a newbie. :-) Thank you a lot. :-)
#4

[eluser]Scriptor[/eluser]
To expand a bit, $1 is the first set of parentheses, $2 is the second, and so on.




Theme © iAndrew 2016 - Forum software by © MyBB