I'm currently in the process of writing a custom routeHandler in Kohana 3.0. Basically a large portion of my site is related to specific items, so rather than have a load of controllers then actions then id's appearing in the URL I'd rather just have the name. Which of course means I need to manipulate the routes.
My bootstrap contains the following:
Route::set('routeHandler', '(<url>)',
array(
'url' => '[a-zA-Z0-9_/-]+',
))
->defaults(array(
'controller' => 'routeHandler',
'action' => 'index',
));
This redirects me to my routesHandler controller.
Inside the controller I then set some more routes and eventually make a new request. However, when it comes to getting the uri to pass it appears empty.
$this->request->param('uri'); // Comes back empty?
When I print out the request I get the following info:
Request Object
(
[route] => Route Object
(
[_uri:protected] => ()
[_regex:protected] => Array
(
[url] => [a-zA-Z0-9_/-]+
)
[_defaults:protected] => Array
(
[controller] => routeHandler
[action] => index
)
[_route_regex:protected] => #^(?:(?P[a-zA-Z0-9_/-]+))?$#uD
)
[status] => 200
[response] =>
[headers] => Array
(
[Content-Type] => text/html; charset=utf-8
)
[directory] =>
[controller] => routeHandler
[action] => index
[uri] =>
[_params:protected] => Array
(
)
)
Is there something I have missed in my bootstrap?
I've also noticed a loss of certain variables set in the bootstrap such as base_url
.
Any help would be greatly appreciated.
Since the parameter mentioned in your route is url
and not uri
, try:
$this->request->param('url');