MGP wrote
> Hello, i'm trying to change the template in the dispatch event, by
> catching a variable setted on the controller and using it to set the
> template.
> 
> Like this:
> 
> Controller:
> 
> public function indexAction ()
>     {
>         return new \Zend\View\Model\ViewModel(array(
>             'layout' =>BASE_PATH . '/template/default/example.phtml'
>         ));
>     }
> 
> 
> Module.php:
> 
> private function initLayout ($e)
> {
>    $this->eventManager->attach('dispatch', function($e)
>     {
>          
> $e->getViewModel()->setTemplate($e->getResult()->getVariable('layout'));
>     }, -100);
> }
> 
> 
> But i get this exception:
> 
> Fatal error: Uncaught exception 'Zend\View\Exception\RuntimeException'
> with message 'Zend\View\Renderer\PhpRenderer::render: Unable to render
> template "C:\www\zf2/template/default/example.phtml"; resolver could not
> resolve to a file' in
> C:\www\zf2\system\vendor\zf2\library\Zend\View\Renderer\PhpRenderer.php on
> line 451
> 
> What am i doing wrong? Or is there another way to do it?

Try to debug your full template path and check if that file is physically
there. It looks like your template path is wrong.



-----
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/bootstrap-event-to-change-template-tp4657144p4657145.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com


Reply via email to