I am trying to simply use a custom view helper that is located in /library/my/view/helpers/friends.php
I have this in the application.ini
:
resources.view.helperPath.My_View_Helper = "/my/view/helpers"
This is the helper class:
class My_View_Helper_Friends extends Zend_View_Helper_Abstract {
public function friends() {
$str = "hello world";
return $str;
}
}
This is in the view file:
<?php echo $this->friends(); ?>
I get an error on this line saying it can't find the plugin in a path that it is already in.
The error:
Plugin by name 'Friends' was not found in the registry; used paths: My_View_Helper_: /My/View/Helpers/ Zend_View_Helper_: Zend/View/Helper/;C:/http/xampplite/htdocs/zf-tutorial/application/views\helpers/
Looks like its using the right path and the file is there. I don't understand why it can't find it?
$this->helper()
to make it work. Also my view helpers are allZend_View_Helper_MyHelper
(maybe try a rename) although I don't put them in the library, I keep them in/views/helpers
to keep things simple. You didn't mention if you added theautoloaderNamespaces[] = MY_
to your application.ini. Not sure if that would be a factor or not. – RockyFord$this->helper()
because you are naming your classesZend_View_Helper_XXX
(if I read that correctly). Only classes officially belonging to ZF should be prefixed withZend_
orZendX_
(See ZF Naming Conventions). It might have to do with the autoloader looking in the Zend directories for your helper classes. – drew010$this->MyHelper()
prefixing withZend_View_Helper_XXX
is the default. So I don't have to register a new helper path. They are stored in any of my/views/helpers
directories. Someday I'll put them all in one place, when I cleanup the application. Also the question has been cleaned up since I posted, so my post makes less sense :) – RockyFord