Access the non-direct View Helper methods in Zend Framework

Something that was temporarily puzzling me so I thought I would post about it. As in most examples to access the direct() method of a View Helper, you simply call the class name on the View Object:

$view->baseUrl();

But if you want to access any of the methods other than direct() you’ve got to get the Helper first, as unlike most Action Helpers they don’t implement a fluent interface because they return bits of the view instead (usually HTML)

$this->getHelper('BaseUrl')->setBaseUrl();

1 Comment

  • Thanks very much. This information was very helpful and was not available as commonly as one would have thought. Appreciate your gesture in making it available to all. Rgds, Vijay

Leave a comment