0

Is there any way to display header and footer in controller method without using

$this->loadLayout();
$this->renderLayout();

these two lines in a controller method.

I have created one template file for controller method but that template data is not displaying in my controller method.

When I am printing

 Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles());

in controller method then it is printing an empty array.

enter image description here

1 Answer 1

0

**For getting header& footer,you can try below code:

 $this->getLayout()->createBlock('page/html_header');->setTemplate('page/html/header.phtml')->toHtml();

 $this->getLayout()->createBlock('page/html_footer');->setTemplate('page/html/footer.phtml')->toHtml();

But,Without $this->loadLayout(); you cannot get header and footer properly.


Better idea to remove content area section from page using $this->getLayout()->getBlock('root')->unsetChild('content');

You can try also below:

public function IndexAction()
    {
        $this->loadLayout();
      $this->getLayout()->getBlock('root')->unsetChild('content');
    $this->renderLayout();

    }

Also you can remove breadcrumbs by add $this->getLayout()->getBlock('root')->unsetChild('breadcrumbs');

4
  • Sorry @Amit but it is not working.
    – vedu
    Feb 17, 2016 at 12:04
  • nothing is working. I have added screenshot of controller method.
    – vedu
    Feb 17, 2016 at 12:13
  • when I add $this->loadLayout(); $this->renderLayout(); these lines then (content displaying in image) is displayed.
    – vedu
    Feb 17, 2016 at 12:18
  • Please check now...
    – Amit Bera
    Feb 17, 2016 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.