2
votes

it work ok on localhost ,but on host it error :

Zend\View\Renderer\PhpRenderer::render: Unable to render template "Application\Index\test"; resolver could not resolve to a file

my controller:

namespace Application\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class IndexController extends AbstractActionController
{
    public function indexAction()
    {
        $view=new ViewModel();
        $view->setTemplate('Application\Index\test');       
        $view->setVariable('view_chat', 'undercut');        
        return $view;
    }
    public function testAction(){

    }
}

view folder:

--/application

----/index

------/index.phtml

------/test.phtml

1

1 Answers

4
votes

Set the view/partial up in module.config.php:

yoursite\module\Application\config\module.config.php

In that file you set up aliases for your partials that you want to use in your site. You do so like this:

<?php 
 // .... Other stuff above
 'view_manager' => array(
     'template_map' => array(
           'test_view' => __DIR__ . '/../view/application/Index/test.phtml 
      )
  )

Then, in your controller, you will be able to set your view to the alias "test_view" like so

 $view->setTemplate('test_view');     

Look for an existing template map because that is where your layout is referenced.