
Wednesday, May 5, 2010 | 0 comments
zendframework zend_view
These helpers are a useful tool in ZendFramework, most often used to save code or perform tasks that otherwise would be very difficult or expensive.
The simplest way to use a "Helper" is in a View:
<base href="<?phpecho$this->baseUrl();?>" />
but we can also use them within a controller, or where we have access to the current view
<?php$this->_helper->getHelper('thehelper');
Most Class Helpers Zend_View_Helper_Abstract descederan for extra functionality already implemented so as access to system objects, but also can make simple assistants without additional overhead, see a helper that shows the date,
<?php/** * Localized Date */classNews_View_Helper_Pintafecha{/** * Actualo Date * * @return string */publicfunctionpintafechas(){$date=newZend_Date();return$date->get(Zend_Date::DATE_FULL);}}
Thus we can save young aides to code and give consistency to the programs.
Remember that the helper's must be located within our directory tree at:
../application/views/helpers../application/modules/<module>/views/helpers
taking the latter limited visibility to your module, if desired helpers have wide application located in our library, maintaining "good practices", in:
..library/My/View/Helper
and report their existence to the system of codes:
<?php$view->setHelperPath('/path/to/more/helpers','My_View_Helper');
or in the configuration file:
....resources.view.helperPath.My_View_Helper="My/View/Helper"
If you need more power, we will inherit from another class Zend_View_Helper_Abstract or descent, more specialized.
No comments for this article.
Feel free to write whatever you want that is related to the article.

+34 677 62.74.00