Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

getRender cannot be invoked more than once

I have a problem that view getRender function can be invoked once (or once per one file) otherwise there is some uncatchable error and script ends without error message.

F.e. when i do this:

$contentsIndex= $this->view->getRender('controller', 'index'); 

It's ok, but when I do this:

$contentsIndex= $this->view->getRender('controller', 'index'); 
$contentsIndex= $this->view->getRender('controller', 'index'); 

It's bad (of course this double code is for testful purpose). I tested it for a simple volt file which had some simple chars, and cloning the view didn't help.

I need it because my controllers have the same searchAction. And finally i decided to make a non action search version and i need to render the results into variable. The issue is not my code related..

Could anybody help? Is this a bug?

Can you try again using Phalcon from the 2.0.x branch?

edited May '15

Andres you rightly noticed i have less than 2.0. At the moment i don't have it installed and cannot do it right away. Doesn't 2.0.x have the problem?

Update: Ok, i've just installed 2.0 windows dll (wine in linux) and my app doesn't work out of box and there is as i see at the moment only one simple page working from my heavy app so i need to optimise it and figure out the places the app stops working. (update- routing is ok i see more pages working)Even default routing doesn't work as it used to. Must read about it all first.

So what with getRender under 2.0.x ? Can anyghing be done in 1.3.x ?


This should work for 1.3.x branch and why not for 2.x branch.

$this->view->start(); $this->view->render('controller', 'action'); $this->view->finish(); $contentsIndex=$this->view->getContent();

Or something like that. I don't know there can be any implications by using this several times but at first glance it's working exactly as it should.

Thank you Andres for your assisting.