1

我的应用程序.ini

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"

bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
test.bootstrap.path = APPLICATION_PATH "/modules/test/Bootstrap.php"
test.bootstrap.class = "Test_Bootstrap"

appnamespace = "Application"

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"

resources.view.basePath = APPLICATION_PATH "/views/"

resources.view[] =
test.resources.view[] = 

db.adapter = "PDO_MYSQL"
db.params.dbname = "money"
db.params.username = "root"
db.params.password = "**************"

resources.modules[] =
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

应用程序/模块/测试/bootstrap.php

class Test_Bootstrap extends Zend_Application_Module_Bootstrap
{
    protected function _initLeftMenu()
    {
        $this->bootstrap('View');
        $view = $this->getResource('View');
        $view->render('index/_left_menu.phtml'); // <-- here error
    }
}

有问题$view->render

致命错误:未捕获的异常“Zend_View_Exception”,消息“未设置视图脚本目录;无法在 C:\ZendFramework\library\Zend\View\Abstract.php:973 中确定视图脚本的位置 堆栈跟踪:#0 C:\ZendFramework\library\Zend\View\Abstract.php(884): Zend_View_Abstract- >_script('_left_menu.phtm...') #1 E:\www\money2\application\modules\test\Bootstrap.php(19): Zend_View_Abstract->render('_left_menu.phtm...') #2 C:\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstract.php(667): Test_Bootstrap->_initLeftMenu() #3 C:\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstract.php(620): Zend_Application_Bootstrap_BootstrapAbstract- >_executeResource('leftmenu') #4 C:\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstract.php(584):

任何的想法?

4

2 回答 2

0

消除test.resources.view[] =

模块中的视图资源替换了主引导程序中的视图。

提示:
$this->getApplication();在模块中 bootstrap 将返回 main bootstrap
使用它来引导和检索视图。

class Test_Bootstrap extends Zend_Application_Module_Bootstrap
{
    protected function _initLeftMenu()
    {
        //main bootstrap, injected by modules resource
        $bootstrap = $this->getApplication();
        $bootstrap->bootstrap('View');
        $view = $bootstrap->getResource('View');
        $view->render('index/_left_menu.phtml'); // <-- here error
    }
}

顺便说一句,引导程序不是渲染某些东西的好地方。考虑将其移至更合适的位置。例如动作助手。
另请查看此博客文章

于 2011-07-24T18:11:42.927 回答
0

找到自己的救赎:application.ini

test.resources.view.basePath = APPLICATION_PATH "/modules/test/views/"
于 2011-07-25T18:19:32.993 回答