通常它会是这样的结构:
../application/modules/somemodule/views/scripts/index/index.phtml
我如何将其移动到:
../application/templates/somemodule/template1/views/......
../application/templates/somemodule/templateTWOOMG/.......
??
最佳答案
您需要使用:$viewRenderer::setViewBasePathSpec();
例如在 frontController
插件中(或者在 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
类中的 getter 和 setter。有很多方法可以自定义默认目录结构。
关于php - 如何移动Zend_Layout的 "views",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2450497/