rendering layout on the production server

67 views Asked by At

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!

2

There are 2 answers

4
unclexo On

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.

1
pia-sophie On

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