15

Is it possible in Zend View helper (extends Zend_View_Helper_Abstract) get info about module/controller/action in which that helper was called ?

Charles
  • 50,943
  • 13
  • 104
  • 142
hsz
  • 148,279
  • 62
  • 259
  • 315

1 Answers1

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();
Vaidas
  • 968
  • 9
  • 22
Mark
  • 6,254
  • 1
  • 32
  • 31