Might be a ridiculous question, but Is there a way to get the actual controller name from the controller class itself?
like
class SomeController extends Zend_Controller_Action {
public function init() {
$controllerName = $this -> getControllerName();
// And get "Some" as a output
}
}
public function init() {
echo Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
}
You can get controller name from request using getControllerName()
. To get to the request (without singletons), you can do following:
public function init() {
$controllerName = $this->_request->getControllerName();
// or
$controllerName = $this->getRequest()->getControllerName();
// or
$controllerName = $this->getFrontController()->getRequest()->getControllerName()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With