在我的layout.phtml文件中我有:
<?PHP echo $this->Test(); ?>
我在应用程序/ views / helpers / Test.PHP创建了一个测试视图助手
<?PHP class My_View_Helper_Test extends Zend_View_Helper_Abstract { public function Test() { return 'test'; } }
和我的配置文件@ configs / application.ini:
resources.view[] = '' resources.view.helperPath = APPLICATION_PATH "/views/helpers"
我得到的错误
Zend_Loader_PluginLoader_Exception:
Plugin by name ‘Test’ was not found in
the registry; used paths:
Zend_View_Helper_:
Zend/View/Helper/:./views/helpers/ in
/usr/share/PHP/Zend/Loader/PluginLoader.PHP
on line 406
resources.view.helperPath.Admin_View_Helper = APPLICATION_PATH "/modules/admin/views/helpers"
我的模块/ admin / views / helpers / AdminPanel.PHP:
<?PHP class My_View_Helper_AdminPanel extends Zend_View_Helper_Abstract { public function AdminPanel() { return 'test'; } }
我不得不使用addHelperPath在Bootstrap中执行此操作?如果有人证明我会如何使用我的路径呢?
使用application.ini可能是定义这些的最好方法.我将所有的视图帮助器放在我的库文件夹中:
includePaths.library = APPLICATION_PATH "/../library" autoloadernamespaces.0 = "SNTrack_" ; -- Note,these are the only resources.view lines I have... resources.view.doctype = "XHTML1_STRICT" resources.view.helperPath.SNTrack_View_Helper = APPLICATION_PATH "/../library/SNTrack/View/Helper"
目录结构:
/ application/ library/ SNTrack/ View/ Helper/ Test.PHP
视图:
$this->test('test')
SNTrack /查看/助手/ test.PHP的:
class SNTrack_View_Helper_Test extends Zend_View_Helper_Abstract { public function test($args) { return $args; } }