2010年8月9日星期一

Re: [fw-mvc] View Helper classes - help! 'Plugin by name... not found in the registry'

The second argument to addHelperPath should just be 'My_View_Helper'.

    -- Mon


On Mon, Aug 9, 2010 at 7:58 PM, Rishi Daryanani <rishijd@yahoo.com> wrote:
Hi all,

This is probably an easy one but I am really confused. I am trying to use a helper for the first time on my zend-framework based site, and I've followed the example on
http://devzone.zend.com/article/3412

My new helper is called CoremetricsTags.php, and it is in the /application/views/helpers/ directory,
and it has the following code (sample):
[PHP]
require_once 'Zend/View/Helper/Abstract.php';
class My_View_Helper_CoremetricsTags extends Zend_View_Helper_Abstract {
   public function coremetricsTags()
    {
        // build the element
        $xhtml = 'test';    
        return $xhtml;
    }
}
[/PHP]

My view index.phtml is calling the helper as follows as a test:
[PHP]
$this->coremetricsTags("coremetrics");
[/PHP]

And this generates an error from the error.phtml file, as follows:
Message: Plugin by name 'CoremetricsTags' was not found in the registry; used paths: My_View_Helper_CoremetricsTags_: ../application/views/helpers/ Zend_View_Helper_: Zend/View/Helper/:../application/views/helpers/

I'm not sure why it happens. I'm a little confused by the addHelperPath and where to use it, but I did do this but it didn't solve the problem (no real effect):
[PHP]
$this->addHelperPath('../application/views/helpers/', 'My_View_Helper_CoremetricsTags');
[/PHP]

Can anyone help?

Many thanks,
Rishi



没有评论: