Reputation: 268334
What is the best way to determine which Controller class a Kohana application is presently using?
Examples:
http://sitesite.com/
- _defaultControllerName_
http://somesite.com/frontpage/articles
- "frontpage"http://somesite.com/contact/
- "contact"Upvotes: 3
Views: 1308
Reputation: 90746
For Kohana 3.x, you need to get the current controller from the Request object:
echo Request::$current->controller();
Upvotes: 5
Reputation: 268334
The following applies to Kohana 2 instances...
You can do this by using the Router library. By default, this library is located in /system/libraries/Router.php
- go ahead and copy it into /application/libraries
as is the standard practice for all libraries being used.
Now, from within your application you can get the controller value from the static Router class:
print Router::$controller; // outputs current Controller
Upvotes: 6