How To Access View Object From View Helper

From your view helepr you might want to access

  • view object properties
  • the view object
  • another view helper

You will be able to do all of the above if the view object is available in your view helper. To make sure view object is available to your helper do any of the following

  • Easiest method: Extend Zend_View_Helper_Abstract

    class My_View_Helper extends Zend_View_Helper_Abstract{}
  • Implement the Zend_View_Helper_Interface
  • Define the setView() method in your helper

    public $view;

    function setView(Zend_View_Interface $view) {
    $this->view = $view;

Once the view object is accessible in your view helper, you can call another view helper. For example,


FOSS Project: 


Very Good, this solve my problem!

Add new comment