Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend - how to disable layout on a given action?

I have the following controller that, among other methods it has this one:

class EquipasController extends OccControllerAction {

    public function listaAction()
    {    
        $this->_helper->viewRenderer->setNoRender(true);
        $this->_helper->layout->disableLayout();
    }
}

I was expecting that, when I do: http://www.example.com/equipas/lista/

the controller will execute and I will see no layout rendering on my viewport.

However, that's not the case. I get my home page rendered.

Where on ZF do we normally say: if an action doesn't exist a home page should appear?

Note: If, instead of: http://www.example.com/equipas/lista/

I do, http://www.example.com/equipas/adasdas21232131/ that doesn't exist.

I get the same home page rendering.

What could be the cause for such a behaviour?

A Zend Newbie, MEM

like image 736
MEM Avatar asked Nov 26 '10 18:11

MEM


2 Answers

Add this inside your controller:

public function preDispatch(){
        $this->_helper->layout()->disableLayout(); 
        $this->_helper->viewRenderer->setNoRender(true);
    }
like image 172
liding Avatar answered Dec 09 '22 23:12

liding


This may not answer your question directly (which you seem to have solved anyway), but to disable the layout and deliver a different view for AJAX requests, consider using the AjaxContext action helper.

like image 37
Phil Avatar answered Dec 10 '22 00:12

Phil