In your view scripts, often it is necessary to perform certain complex functions over and over: e.g., formatting a date, generating form elements, or displaying action links. You can use helper classes to perform these behaviors for you.
A helper is simply a class. Let's say we want a helper named 'fooBar'.
By default, the class is prefixed with 'Zend_View_Helper_'
(you can specify a custom prefix when setting a helper path), and the
last segment of the class name is the helper name; this segment should
be TitleCapped; the full class name is then:
Zend_View_Helper_FooBar. This class should contain at the
minimum a single method, named after the helper, and camelCased:
Watch the Case
Helper names are always camelCased, i.e., they never begin with an uppercase character. The class name itself is MixedCased, but the method that is actually executed is camelCased.
Default Helper Path
The default helper path always points to the Zend Framework view
helpers, i.e., 'Zend/View/Helper/'. Even if you call
setHelperPath() to overwrite the existing paths, this
path will be set to ensure the default helpers work.
To use a helper in your view script, call it using
$this->helperName(). Behind the scenes,
Zend_View will load the
Zend_View_Helper_HelperName class, create an object
instance of it, and call its
helperName() method. The
object instance is persistent within the
instance, and is reused for all future calls to