How to write your own helpers and override default helpers
Since we're talking about a view helper, the code for it can be found in library\Zend\View\Helper\Partial.php
. If you want to change what the partial view helper does, write your own helper:
class MyProject_View_Helper_MyHelper extends Zend_View_Helper_Abstract {}
or
class MyProject_View_Helper_MyHelper implements Zend_View_Helper_Interface {}
and then add this helper to the helper stack by adding the path to it to your configuration.
resources.view.helperPath.MyProject_View_Helper_ = "MyProject/View/Helper/"
If you call your helper Partial
, you can completely override the default partial helper.
See also this blog about view helpers by Akrabat.
And, to put it in your words...
...how Zend_View aquires the partial method
If a helper is registered, it can be called from the view because of the following code in Zend_View_Abstract
/**
* Accesses a helper object from within a script.
*
* If the helper class has a 'view' property, sets it with the current view
* object.
*
* @param string $name The helper name.
* @param array $args The parameters for the helper.
* @return string The result of the helper output.
*/
public function __call($name, $args)
{
// is the helper already loaded?
$helper = $this->getHelper($name);
// call the helper method
return call_user_func_array(
array($helper, $name),
$args
);
}