Is it possible in Zend View helper (extends Zend_View_Helper_Abstract
) get info about module/controller/action in which that helper was called ?
Asked
Active
Viewed 1.5k times
15
1 Answers
35
Yes. You can use Zend_Controller_Front::getInstance()
within view helpers. So you could do something like this:
class App_Helper_DoSomething extends Zend_View_Helper_Abstract
{
public function doSomething()
{
return Zend_Controller_Front::getInstance()
->getRequest()
->getControllerName();
}
}
Which will print the current controller name when called in your view with:
echo $this->doSomething();
-
how would you get the module name? is that possible? – chrisjlee May 15 '12 at 03:28
-
chrisjlee : Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); – Aakash Sahai Feb 01 '13 at 07:44