Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How it's possible to disable rendering layout in case of xmlhttprequest in phalcon framework?

How can be disabled layout rendering?

For a moment i can detect that request is made via jQuery this way:

public function initialize()
{
    if (!$this->request->isAjax()) {
        // disable layout here... how?
    }
}

Could it be done globally?

Code for handling ajax requests will be the same for all controlles, is there a way to define this behaviour rule globally for whole application?

like image 811
avasin Avatar asked Dec 18 '12 02:12

avasin


1 Answers

public function initialize()
{
    if (!$this->request->isAjax()) 
    {
        // disable layout here... how?
        $this->view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_ACTION_VIEW);
    }
}

Also you could disable the auto rendering by calling

$this->view->disable();
like image 51
Nikolaos Dimopoulos Avatar answered Nov 05 '22 01:11

Nikolaos Dimopoulos