Zend framework 更改Zend Framework模块视图脚本路径
当前查看位于Zend framework 更改Zend Framework模块视图脚本路径,zend-framework,view,module,path,Zend Framework,View,Module,Path,当前查看位于应用程序路径中的脚本/模块/my_模块/views/scripts/'。我想将脚本放在'/modules/my_module/views/'(删除脚本文件夹)中。如何做到这一点 application.ini: resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" resources.modules[] = resources.view.scriptPath.default = APPLICAT
应用程序路径中的脚本/模块/my_模块/views/scripts/'
。我想将脚本放在'/modules/my_module/views/'
(删除脚本文件夹)中。如何做到这一点
application.ini:
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] =
resources.view.scriptPath.default = APPLICATION_PATH "/views"
可以使用view方法替换脚本路径
您还可以使用添加脚本路径,而无需覆盖上一个脚本路径。我使用它来组织不同文件夹中的视图脚本
希望对…有所帮助。我创建了一个插件:
class Application_Model_Controller_Plugin_AddScriptPath extends Zend_Controller_Plugin_Abstract
{
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) {
$view = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer')->view;
$scriptPath = sprintf('%s/modules/%s/views',
APPLICATION_PATH,
$request->getModuleName());
if (file_exists($scriptPath)) {
$view->addScriptPath($scriptPath);
}
}
}
并在application.ini中注册:
resources.frontController.plugins[] = "Application_Model_Controller_Plugin_AddScriptPath"
我知道这很古老,但它可能会帮助别人。我也有同样的问题。我通过使用
resources.view.scriptPath = APPLICATION_PATH "/views/"
如果要更改任何操作的视图脚本
在控制器操作中添加以下内容:
$this->view->addScriptPath(应用程序路径。'your/PATH')
$this->renderScript('list.phtml')