Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

What’s the function of $this->loadLayout() and $this->renderLayout()? 
 
Emperor
Sr. Member
 
Total Posts:  111
Joined:  2007-08-31
 

I need to know what’s the role of the following functions. An indepth view would help alot.

$this->renderLayout() and $this->renderLayout()

 
Magento Community Magento Community
Magento Community
Magento Community
 
retif
Sr. Member
 
Total Posts:  171
Joined:  2008-08-16
Odessa, Ukraine
 

they do exactly as they named smile first loads layout/*.xml, second creates html from phtml

 
Magento Community Magento Community
Magento Community
Magento Community
 
pbklik
Jr. Member
 
Total Posts:  3
Joined:  2010-08-05
 

how we can secify particular layout like 1column.phtml?

 
Magento Community Magento Community
Magento Community
Magento Community
 
FishPig
Sr. Member
 
Avatar
Total Posts:  232
Joined:  2009-06-05
 

The following code will load the layout structure, set the page template and then render and display the content

<?php

    $this
->loadLayout();
    
$this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
    
$this->renderLayout();
 
Magento Community Magento Community
Magento Community
Magento Community
 
MagePsycho
Moderator
 
Avatar
Total Posts:  1702
Joined:  2009-06-23
 

This loads the default layout assigned to the module:

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

In order to customize it, you can do some block injection as:

$this->loadLayout();
//your layout updates here
$this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
$this->renderLayout();
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top