Kohana 3.3 send parameter to default action

94 Views Asked by At

I have an example controller called Home. The default method, set in the bootstrap is action_index(). I also have a page that redirects to the url 127.0.0.1/home/123123 , where 123123 should be a parameter. But Kohana is actually trying to access a controller, named 123123. How can I set the route to /home/[parameter] ?

1

There are 1 best solutions below

0
SigmaSteve On

The URL you need to redirect to is 127.0.0.1/home/index/123123 so that it knows the method you're wanting to use as well. It will only use the default action_index() method if everything after home/ is omitted.

You could potentially do it without the /index but you'd need some logic in the before() to check whether the parameter was === 'index' and then if not, store it as a variable and then run the index method manually.

The docs on Routing may be of some help.