Route::set('category', 'category/date/<id>(/<year>)', array('id' => '[0-9]+', 'year' => '[0-9]+'))
->defaults(array(
'controller' => 'category',
'action' => 'date',
));
Is there any cap for parameters on a kohana 3.2 route?
I’ve implemented this route in my bootstrap but everytime I try to pass the year value I get a 404 error!
Passing of the ID alone just works fine.
Am i missing anything?
This is the controller action for handling this route:
public function action_date() {
$id = $this->request->param('id');
$year = $this->request->param('year');
if(!isset($year) && $year == ""){
$year = date("Y", time());
}
//Do fancy stuff here... and hand it to the view!
}
Kohana should route that to the right action, and it does for me. My guess is that you either overwrite that route with one also named ‘category’ or it gets matched by another route which action throws a Kohana_Exception_404.
You should be able to dissmiss/verify if a Kohana_Exception_404 is thrown from a method by looking at the stack trace.
Route names are used as key names for the array in which the routes are stored as can be seen below. Using the same name twice would overwrite the previous route which was under that name.
You could use the following in a action somewhere to see all the routes used for routing:
$this->response->body(Debug::vars(Route::all()));Then you are able to check the compiled regex of the ‘category’ route or similar.