我想将变量发送到zend框架中的布局,我试图创建一个控制器插件并将其放入
application
/plugins
并将文件命名为layout.php
,以下是layout.php
class Plugin_Layout extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$layout = Zend_Layout::getMvcInstance();
$view = $layout->getView();
$view->foo = 'bar';
}
}
现在我想在application.ini
中使用frontController注册该插件,我尝试添加
includePaths.plugin = APPLICATION_PATH "/plugins"
autoloaderNamespaces[] = "Plugin_"
resources.frontController.plugins[] = "Plugin_Layout"
它显示我跟随错误。
Warning: include_once(Plugin/Layout.php) [function.include-once]: failed to open stream: No such file or directory in /Users/azhararmar/htdocs/joofris/library/Zend/Loader.php on line 146
我是zend框架的新手。我哪里错了?
答案 0 :(得分:2)
添加 application.ini :
pluginPaths.Plugins = APPLICATION_PATH "/Plugins"
将resources.frontController.plugins[] = "Plugin_Layout"
重命名为resources.frontController.plugins.Layout = "Plugin_Layout"
,但frontController.plugins[]
仍应有效。
并将插件文件夹重命名为插件,将 layout.php 文件重命名为 Layout.php ,这个应该工作。
答案 1 :(得分:1)
你的路径应该是
includePaths.plugin = APPLICATION_PATH "/Plugins"
注意大写P.