We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Rendering a view with alternate main layout


I've inherited an existing website based on phalcon and angularjs with volt view engine. So far I've been successful with fixing problems with existing pages, using the configuration set up by the previous devloper. But we have some new use cases that are out of the scope of the previous setup. I'm having trouble achieving what I want without break the old configuration.

I want to define a new main layout different from old main layout and render viewes with the new main layout. I have defined the new main layout in:


I have a the view I want to render inside the main layout in:


I have a controller in:


Following is my controller code:


use Phalcon\Mvc\Controller;
use Phalcon\Mvc\View;

class NewController extends Controller

  public function indexAction() {





This is as close as I can get it to work. The layout however is not picked up. Only the contents of new/index.volt is rendered. Please help!!


try with


Using only: $this->view->setTemplateAfter('newLayout'); Does not work I am getting the regular views/Index.volt

If I add it to my other code it has no effect.

try with



me i have jsut this one

public function indexAction(){


and the 2 layouts are in the same dir. Try that, also try removing view->pick just to check if its chreweing it up

Sorry. Removing pick didn't work.


Solved it! I moved newLayout.volt to:


and in the controller I now only have:

public function indexAction() {