Quantcast

View Helper classes - help! 'Plugin by name... not found in the registry'

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

View Helper classes - help! 'Plugin by name... not found in the registry'

Rishi Daryanani
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


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

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

    -- Mon


On Mon, Aug 9, 2010 at 7:58 PM, Rishi Daryanani <[hidden email]> 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



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Rishi Daryanani
Hi Mon,
Thanks very much :-) Worked great! Quick question, should the following code:
$this->addHelperPath('../application/views/helpers/', 'My_View_Helper');
be called in the view index.phtml file, or should it be called in bootstrap or a controller file? If so, how? (e.g. how do I reference the view, if it were on the bootstrap?)
It's not a big deal at the moment but I just want to follow the standard.

Many thanks,
Rishi


From: Mon Zafra <[hidden email]>
To: [hidden email]
Sent: Mon, August 9, 2010 5:41:33 PM
Subject: 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 <[hidden email]> 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




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Ashish Sood
Rishi:

In Bootstrap, you may create a new instance of View, add new helperPath  and then register it with the frontController. Then onwards your actionControllers will use your instance of View. If you do this way then of-course the change will be applicable to all the Controllers.

Alternatively, you can add the helperPath in the particular Controller(s), say in preDispatch() hook, you want the change to appear.

I hope I didn't confuse you further :-)

ashish sood

From: Rishi Daryanani <[hidden email]>
To: [hidden email]
Sent: Mon, August 9, 2010 11:44:10 AM
Subject: Re: [fw-mvc] View Helper classes - help! 'Plugin by name... not found in the registry'

Hi Mon,
Thanks very much :-) Worked great! Quick question, should the following code:
$this->addHelperPath('../application/views/helpers/', 'My_View_Helper');
be called in the view index.phtml file, or should it be called in bootstrap or a controller file? If so, how? (e.g. how do I reference the view, if it were on the bootstrap?)
It's not a big deal at the moment but I just want to follow the standard.

Many thanks,
Rishi


From: Mon Zafra <[hidden email]>
To: [hidden email]
Sent: Mon, August 9, 2010 5:41:33 PM
Subject: 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 <[hidden email]> 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




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Wil Moore III
In reply to this post by Rishi Daryanani
Rishi Daryanani wrote
should the following code:
$this->addHelperPath('../application/views/helpers/', 'My_View_Helper');
be called in the view index.phtml file, or should it be called in bootstrap or a
controller file? If so, how? (e.g. how do I reference the view, if it were on
the bootstrap?)  
This is best done as a bootstrap resource. See the section "Getting started with Bootstrap Resources" in the following article for more info:
http://weierophinney.net/matthew/archives/230-Quick-Start-to-Zend_Application_Bootstrap.html

The main take-away from the article is the following few lines:

 Bootstrap resources may be one of two things:

    * A protected method in the bootstrap class prefixed with "_init"; e.g., "protected function _initFoo()"
    * A class implementing Zend_Application_Resource_Resource


This should be enough to get you moving in the right direction.

--
Wil Moore III

Best Practices for Working with Open-Source Developers
http://www.faqs.org/docs/artu/ch19s02.html

Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html

DO NOT TOP-POST and DO trim your replies:
http://linux.sgms-centre.com/misc/netiquette.php#toppost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Rishi Daryanani
Hi all,

Thanks very much for your responses! My coworker/developer did this as follows from bootstrap:

/* Set helper path for our custom helpers */
$view = new Zend_View;
$view->addHelperPath('../application/views/helpers/', 'My_View_Helper');
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setView($view);

However if the above is not what is recommended for any reason (e.g. Wil Moore's recommendation below is different) please feel free to let me know :)

Additionally, another related question:

2) If I wanted to code up a different functionality which needs to be accessed by the controller, and use a shared class file with functions that I can access from different areas of the site, what would be your recommendation? Would you use a normal class file and include it from the controllers where you need to use it, or would you use an "action helper" (http://devzone.zend.com/article/3350) , or something else?

Thanks,
Rishi



From: Wil Moore III <[hidden email]>
To: [hidden email]
Sent: Tue, August 10, 2010 8:55:22 PM
Subject: [fw-mvc] Re: View Helper classes - help! 'Plugin by name... not found in the registry'



Rishi Daryanani wrote:
>
> should the following code:
> $this->addHelperPath('../application/views/helpers/', 'My_View_Helper');
> be called in the view index.phtml file, or should it be called in
> bootstrap or a
> controller file? If so, how? (e.g. how do I reference the view, if it were
> on
> the bootstrap?) 
>
This is best done as a bootstrap resource. See the section "Getting started
with Bootstrap Resources" in the following article for more info:
http://weierophinney.net/matthew/archives/230-Quick-Start-to-Zend_Application_Bootstrap.html

The main take-away from the article is the following few lines:

Bootstrap resources may be one of two things:

    * A protected method in the bootstrap class prefixed with "_init"; e.g.,
"protected function _initFoo()"
    * A class implementing Zend_Application_Resource_Resource


This should be enough to get you moving in the right direction.



-----
--
Wil Moore III

Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/View-Helper-classes-help-Plugin-by-name-not-found-in-the-registry-tp2318421p2319962.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Wil Moore III
Rishi Daryanani wrote
/* Set helper path for our custom helpers */
$view = new Zend_View;
$view->addHelperPath('../application/views/helpers/', 'My_View_Helper');
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setView($view);
If you are using Zend_Application, you can do this instead:

; application.ini
resources.view.helperPath.My_View_Helper          = APPLICATION_PATH "/views/helpers"


Obviously this assumes that your constant "APPLICATION_PATH" is pointing to what is equivalent to your "../application/" shown in your above call to $view->addHelperPath(...).

Also, if you are using Zend_Application and you've already configured the view resource (eg: you have something in your application.ini that starts with "resources.view.") then you don't need to do:
$view = new Zend_View since there is already a view instance available to the bootstrap...you just have to get it.


// bootstrap view resource
$this->bootstrap('View');
/* @var Zend_View */
$view = $this->getResource('View');

--
Wil Moore III

Best Practices for Working with Open-Source Developers
http://www.faqs.org/docs/artu/ch19s02.html

Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html

DO NOT TOP-POST and DO trim your replies:
http://linux.sgms-centre.com/misc/netiquette.php#toppost
Loading...