View Helper Case Notes

This is how it works:

views/helpers/MyHelper.php contains class Zend_View_Helper_MyHelper which has a function called myHelper()

Also, if you add a function called setView() to your class, then the View will pass you an instance of itself before it calls your view helper function.

i.e.


Class Zend_View_Helper_MyHelper
{
    protected $_view;
    
    public function setView($view)
    {
        $this->_view $view;
    }

    public function myHelper($myVar)
    {
         return $this->_view->escape($myVar);
    }

}

If you would like to comment on this article, please ping me on twitter.
If your response won't fit into 140 characters, write a blog post and then ping me!