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 <wil.moore@wilmoore.com>
To: fw-mvc@lists.zend.com
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.
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 <wil.moore@wilmoore.com>
To: fw-mvc@lists.zend.com
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.
没有评论:
发表评论