My productionserver is not able to render my loginlayout. On my development system everything works fine.
Here comes the error on the production website:
Fatal error: Uncaught Zend\\View\\Exception\\RuntimeException: Zend\\View\\Renderer\\PhpRenderer::render: Unable to render template "layout/layoutlogin"
How I did this:
My Application/config/module.config.php
gives the templates as follows:
'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',
],
],
In my Indexcontroller I set the Layout to:
$this->layout()->setTemplate('layout/layoutlogin');
That might do what I want!? I get no error and no warning in the development mode on the development environment. Any ideas appreciated!
You may try this way
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;
}
This actually means you are using a layout which is other than the default and then inside this layout you may use template that you want for this.
The error ist solved. Actually it was a server configuration issue. In this case it was that Apache didn't have enough rights for the folder
data/cache
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.