如何移动“视图" Zend_Layout的 [英] How to move the "views" of Zend_Layout
本文介绍了如何移动“视图" Zend_Layout的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通常它将是这样的结构:
Normally it would be in such a structure:
../application/modules/somemodule/views/scripts/index/index.phtml
我如何将其移动到:
../application/templates/somemodule/template1/views/......
../application/templates/somemodule/templateTWOOMG/.......
??
推荐答案
您需要玩:$viewRenderer::setViewBasePathSpec();
例如,在frontController
插件中(或更简单,但不太灵活,在Bootstrap.php
中):
For example in frontController
plugin, (or easier, but not so flexible, in Bootstrap.php
):
$templateName = 'myTemplate';
$bootstrap = $this->getBootstrap();
$bootstrap->bootstrap('layout');
if ($bootstrap->hasResource('layout')) {
$layout = $bootstrap->getResource('layout');
$layout->setLayoutPath($basePath . '/layouts/scripts/');
}
$bootstrap->bootstrap('view');
if ($bootstrap->hasResource('view')) {
$view = $bootstrap->getResource('view');
} else {
$view = new Zend_View;
}
$vr = Zend_Controller_Action_HelperBroker::getExistingHelper("viewRenderer");
$vr->setViewBasePathSpec($basePath."/modules/:module/$templateName/views/");
看看frontController
,view
,layout
和viewRenderer
类中的获取器和设置器.有很多方法可以自定义默认目录结构.
Take a look on getters and setters in frontController
, view
, layout
and viewRenderer
classes. There are plenty of methods which allow to customize default directory structure.
这篇关于如何移动“视图" Zend_Layout的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文