Monday, September 17, 2012

Magento : Change page layout from controller

 Change page layout from controller in Magento



Just you need to replace one line of code in your controller
where you want to change the layout of the page if you are not
able to do from xml through setlayout.

Replace
$this->loadLayout();

with
$this->loadLayout()->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');

6 comments:

  1. Great website...and cool article man...thanx for the great post...keep on posting such articles..

    PHP 5 developer

    ReplyDelete
  2. Nice blog ,looking forward for more articles .
    Magento Developers

    ReplyDelete
  3. The blog posted is very interesting from all aspects and it will surely benefit the readers by all means.
    Magento Developers

    ReplyDelete
  4. I learn some new stuff from it too, thanks for sharing your information.
    http://newizze.com/

    ReplyDelete