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

asked Feb 17, 2016 at 11:46

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');

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.