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

[eluser]haxxorized[/eluser]
Hey, I have a little problem...


Say, if I wanted to go to a link: for example:
www.example.com/link

that would trigger the index function of the 'link' controller,
but say if I wanted to trigger a different function with this link, let's say 'function2'

then I could go to the config file and add to the routes array:
$routes['link'] = 'link/function2';

So that's all OK,
but now I want some parameters to add to that function, and the parameters come from the link...
how do I do that?
#2

[eluser]Rob Gordijn[/eluser]
ok, a fast reply:

Code:
class Link {
  function function2($par1 = '', $par2 = ''){
    echo $par1.' - '.$par2;
  }
}

now call example.com/link/function2/foo/bar Wink
#3

[eluser]Jeremy Gimbel - Conflux Group[/eluser]
You might actually have to add something to your route:

Code:
$routes[‘link/(:any)’] = ‘link/function2/$1’;

Keep in mind that'll kill all the default routing to methods, and you'll need to create routes for each other method.




Theme © iAndrew 2016 - Forum software by © MyBB