0

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!

pia-sophie
  • 505
  • 4
  • 21

2 Answers2

0

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.

unclexo
  • 3,691
  • 2
  • 18
  • 26
  • What would be the reasion, that it works local on the development system, but not on the production? I even deactivated every $this->layout something, it doesn't work atall – pia-sophie Jul 14 '17 at 09:01
  • I'm not sure what is happening behind your code. I have some questions to you! What is your php version? Did you disable development environment? If not use this `composer development-disable` via composer. What php opening tags are you using? "" - do not use this short opening tag. Please check your php.ini config file whether that short tag is on or off. Use "=" or " – unclexo Jul 14 '17 at 10:08
  • its solved, like I guessed it was definitiv a serverissue – pia-sophie Jul 14 '17 at 14:51
  • Great! you made it! :) – unclexo Jul 14 '17 at 15:16
0

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

pia-sophie
  • 505
  • 4
  • 21