Use partials views templates for ajax calls in controller action as response in phalcon

This will be helpful for someone who is willing to create ajax calls by controller action and use partial template instead of default action view template.

Example Say you would have  controller action that will have one view template. now here by using the same  view template   you are going to use it for some other controller action as a partial.

Point is you are going to use one controller action view template for multiple controller actions as  partials.

 

class AController extends ControllerBase
{
	public function getAction() {
    //Set the content of the response
    $this->view->setVar('is_ajax', true);
    $this->view->setVar('somevariable_toview', $somevariable_toview); 
    $content =  $this->view->getPartial('some/other/controller_actions/viewtemplatefile');
    set ajax response instead of whole template render
    $response = new \Phalcon\Http\Response();
    $response->setContent($content);    
    return $response;   
    }
}

 

Thats it