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

How to close the layout?

I have an ajax request and I hope the layout don't work.

What should I do ?



1.7k

This is a sample function that may work for you. Just set the render level then specify the view you want to render as result for that ajax request.

public function latestUpdatesAction($user_id){
    $user = Artists::findFirst(array("id = :id:","bind"=>["id"=>$user_id]));
    $this->view->setVar('user',$user);
    $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
    $this->view->pick('user/user--latest-updates');
}