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

Layout rendering twice

Hello , i am performing an ACL check in my controller's initialize method and setting a layout regarding to role of authenticated user.

php public function initialize(){ $role = $this->sezon->role ? $this->sezon->role : 'visitor' ; if($this->acl->isAllowed($role,$this->dispatcher->getControllerName(),$this->dispatcher->getActionName())){ switch($role){ case "Power" : $this->view->setLayout("power"); break; case "Visitor" ; $this->view->setLayout("visitor"); break; } return true; }else{ $this->response->redirect("admin/login/"); return false; } } This works fine controller wide , but when i try to run the code below ;


it renders layout twice.

P.S : i tried to disable layout at "somecontroller" with no luck.


In hierarchical mode, you don't have to call: render(), it's automatically called by Phalcon\Mvc\Application, that's why you're getting the output twice