Kriss McCone
Kriss McCone

Reputation: 24

Trying to disable layout in zend

I try to disable layout in zend action in this way:

$this->_helper->layout->disableLayout();

But it doesn't work:

 Fatal error: Call to undefined method Application_Controller_Helper_Layout::disableLayout() in application/controllers/AssetController.php on line 18

I reckon that its, because I made my own helper.

Bootsrap.php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initMyActionHelpers()
    {
        $this->bootstrap('frontController');
        $layout = Zend_Controller_Action_HelperBroker::getStaticHelper('Layout');
        Zend_Controller_Action_HelperBroker::addHelper($layout);
    }

}

application.ini

resources.frontController.actionhelperpaths.Application_Controller_Helper = APPLICATION_PATH "/controllers/helpers"

and my helper

class Application_Controller_Helper_Layout extends Zend_Controller_Action_Helper_Abstract
{
    public function preDispatch()
    {
    }
}

Thanks!

Upvotes: 0

Views: 359

Answers (1)

Siwei
Siwei

Reputation: 161

If you want to rewrite Zend default layout helper, please extend Zend_Layout_Controller_Action_Helper_Layout.

class Application_Controller_Helper_Layout extends Zend_Layout_Controller_Action_Helper_Layout

Then you will still be able to use default disableLayout() function if you are not overwriting it in your own helper.

Try testing it using:

class Application_Controller_Helper_Layout extends Zend_Layout_Controller_Action_Helper_Layout
{
    public function preDispatch(){}

    public function disableLayout(){
        echo "I won't disable layout anymore, because I overwrote the action with displaying this string.";
    }
}

Upvotes: 1

Related Questions