php - 如何移动Zend_Layout的 "views"

标签 php zend-framework zend-layout

通常它会是这样的结构:

../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/");

查看一下 frontControllerviewlayoutviewRenderer 类中的 getter 和 setter。有很多方法可以自定义默认目录结构。

关于php - 如何移动Zend_Layout的 "views",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2450497/

相关文章:

php - 如何配置 .htaccess 以在有人访问该站点时运行 php 脚本?

zend-framework - 如何在 Zend Framework 中设置多个布局。例如。公开/登录/多种模块组合

php - 我想创建简单投票而不点击按钮,但它不起作用

php - 我怎样才能 "close"网站只在星期天

oop - 域对象和值对象-它们相等吗?

php - 如何从 zend 框架 1 中的 url 获取参数?

PHP Zend Controller 插件被调用两次

php - 如何更改 zend 框架布局中的元标记

php - Zend_Test_PHPUnit_ControllerTestCase 和 Zend_Layout,运行测试时无法找到布局插件

php - 使用 IP 地址查找纬度和经度