-- TravisJ <[EMAIL PROTECTED]> wrote
(on Wednesday, 22 August 2007, 07:47 AM -0700):
> I'm trying to include custom view helpers in my application but keep getting
> an exception thrown.
>
> A shortened example of my code:
>
> class TJ_View_Helper_SpecialLink
> {
> public function specialLink($variables) {//relevant code here }
> }
>
> When I try and access it from a view script, I get an exception thrown in
> Zend_View_Abstract _loadClass():
> helper 'specialLink' not found in path.
>
> In my bootstrap file I do the following:
> $view = new Zend_View();
> $view->addHelperPath($basedir.'/app/views/helpers', 'TJ_View_Helper');
>
> and Zend_Debug::dump($view->getHelperPaths()) in the bootstrap shows in part
> this:
> array(2) { [0] => array(2) {
> ["prefix"] => string(15) "TJ_View_Helper_"
> ["dir"] => string(47) "/home/username/app/views/helpers/" }
>
> Yet when I dump getHelperPaths in the IndexController, or dump
> _path['helper'] in the view abstract _loadClass function:
> array(2) { [0] => array(2) {
> ["prefix"] => string(17) "Zend_View_Helper_"
> ["dir"] => string(21) "../app/views/helpers/" }
Are you setting your view in the ViewRenderer? My guess is no.
Make sure you have the following lines in your bootstrap, sometime after
you initialize your view object:
$viewRenderer =
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer->setView($view);
If you don't do that, the ViewRenderer creates its own Zend_View
instance -- without the custom paths and options you set already.
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/