5

In an action helper, I can get request using $this->getRequest();

Anything similar for a view helper?

jarn
  • 263
  • 1
  • 2
  • 7

1 Answers1

7

You can use

Zend_Controller_Front::getInstance()->getRequest()

To get the front controller and then the request from that within your view.

Although you should be using the controller to take the request and then pass on the correct data to the view. The view should be independent of the request and decoupled via the controller. Doing this basically breaks the MVC implementation of Zend Framework.

Jake N
  • 10,535
  • 11
  • 66
  • 112
  • 4
    "Doing this basically breaks the MVC implementation of Zend Framework". I agree, but not only that, it violates the principles of MVC, period. – Decent Dabbler Apr 07 '11 at 11:41
  • But what about getting the controller and action from the request in a view helper? As pointed out in this, http://stackoverflow.com/questions/4578391/whats-the-way-to-use-zend-acl-in-view-to-show-hide-parts-of-view I would need to manually pass the view and controller to the acl view helper. Why not just get it from the request? Or should I use some other way around this problem? – Janis Peisenieks Aug 09 '11 at 19:22