0

我的生产服务器无法呈现我的登录布局。在我的开发系统上一切正常。

这是生产网站上的错误:

致命错误:未捕获 Zend\View\Exception\RuntimeException: Zend\View\Renderer\PhpRenderer::render: Unable to render template "layout/layoutlogin"

我是怎么做到的:

Application/config/module.config.php给出的模板如下:

'view_manager' => [
        'display_not_found_reason' => true,
        'display_exceptions'       => true,
        'doctype'                  => 'HTML5',
        'not_found_template'       => 'error/404',
        'exception_template'       => 'error/index',
        'template_map' => [
            'layout/layout'           => __DIR__ . '/../view/layout/layout.phtml',
            'layout/layoutlogin'      => __DIR__ . '/../view/layout/layoutlogin.phtml',
            'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
            'error/404'               => __DIR__ . '/../view/error/404.phtml',
            'error/index'             => __DIR__ . '/../view/error/index.phtml',
        ],
        'template_path_stack' => [
            __DIR__ . '/../view',
        ],
    ],

在我的 Indexcontroller 中,我将布局设置为:

$this->layout()->setTemplate('layout/layoutlogin');

那可能会做我想要的!?在开发环境的开发模式下,我没有收到任何错误和警告。任何想法表示赞赏!

4

2 回答 2

0

你可以试试这个方法

public function loginAction()
{
    // Provide the layout here
    $this->layout('layout/layoutlogin');

    $view = new ViewModel();

    // Here you may set the template
    $view->setTemplate("/module/controller/template");

    return $view;
} 

这实际上意味着您使用的布局不是默认布局,然后在此布局内您可以使用您想要的模板。

于 2017-07-12T17:40:33.923 回答
0

错误解决了。实际上这是一个服务器配置问题。在这种情况下,是 Apache 对该文件夹没有足够的权限

数据/缓存

于 2017-07-14T14:54:31.293 回答