I've read many posts about how to register a custom view helper. This has not been my issue. I have custom view helpers working from my library; however, they seem to only be accessible from the "default" module (i.e. outside of a module). When attempting to call the helper from within a module, I get the following error:
Message: Plugin by name 'IsCurrent' was not found in the registry; used paths: Zend_View_Helper_: Zend/View/Helper/:/Users/firemanrob/Development/Projects/mysite.com/www/application/modules/admin/views/helpers/
As stated above, when I make this call from the outside of a module, it works fine...
if ($this->isCurrent(...
But this same line, in a view script, in a module produces the error.
My helper class is in a file called
library/Sc/View/Helper/IsCurrent.php
The class is defined and function declared as such:
class Sc_View_Helper_IsCurrent extends Zend_View_Helper_Abstract {
public function isCurrent($startTime, $endTime) {
My Bootstrap.php file (among other things) contains this:
function _initViewHelpers() {
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer->setViewSuffix('php');
unset($viewRenderer);
/* @var $view Zend_View */
$view = $layout->getView();
$options = Zend_Registry::get('options');
if (Zend_Registry::isRegistered('db')) {
$this->_db = Zend_Registry::get('db');
} else {
$db = $this->getPluginResource('db');
$this->_db = Zend_Db::factory($db->getAdapter(), $db->getParams());
Zend_Registry::set('db', $this->_db);
}
$view->doctype('HTML5');
$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
$view->headTitle($options->template->websiteBaseTitle);
$view->headTitle()->setSeparator(' | ');
$view->addHelperPath("Sc/View/Helper", "Sc_View_Helper");
}
The only thing my application.ini file contains, pertaining to modules or view helpers is:
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
; setup modules
resources.modules[] =
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
;content settings
content.path = "../application/content"
;layout settings
resources.layout.layoutpath = APPLICATION_PATH "/layouts"
resources.layout.viewSuffix = php
resources.layout.layout = "default"
autoloadernamespaces[] = Amg
autoloadernamespaces[] = Sc
autoloadernamespaces[] = Phpmailer
I've tried commenting out the resources.modules[] line, as I read something similar in another post. That just broke everything.
The particular module that I'm trying to call this from is called "admin" and in that module's folder is another Bootstrap.php file that contains only:
<?php
class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{
}
Any suggestions of how I can make this working view helper visible to my modules as well?
_initViewHelpers
function, since what you posted is clearly only part of it. – Tim Fountain