We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

INVO How to disable layout for a specific controller?

I just want to disable layout from layout/main.volt for some controllers but have no idea, please help



85.5k
Accepted
answer

https://docs.phalcon.io/en/latest/reference/views.html#control-rendering-levels


public function afterExecuteRoute($dispatcher)
    {
$this->view->setRenderLevel(
    View::LEVEL_LAYOUT
);

}


17.5k
edited Sep '16

Can also specify the layout in the initialize method of the controller.

    public function initialize() {
        $this->view->setTemplateAfter('path/to/layout');
    }


3.3k

Thanks a lot, Zach, Izo :D