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.
1 Answer 1
**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');
-
Sorry @Amit but it is not working.vedu– vedu2016年02月17日 12:04:05 +00:00Commented Feb 17, 2016 at 12:04
-
nothing is working. I have added screenshot of controller method.vedu– vedu2016年02月17日 12:13:54 +00:00Commented Feb 17, 2016 at 12:13
-
when I add $this->loadLayout(); $this->renderLayout(); these lines then (content displaying in image) is displayed.vedu– vedu2016年02月17日 12:18:40 +00:00Commented Feb 17, 2016 at 12:18
-
Please check now...2016年02月17日 12:28:37 +00:00Commented Feb 17, 2016 at 12:28