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.

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

```php $this->view->setTemplateAfter('newLayout');



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() {