We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 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 ;

$this->view->render("somecontroller","someaction");

it renders layout twice.

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



98.9k

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