How to update or change page layout in Magento2

In Magento 2, we have page layout same as the page layouts in Magento1 but the implementation is slightly different.

To demonstrate, we choose the customer layout (customer.xml) file which show you how to update 1column.phtml page layout,

In Magento1 we used to update page layout like:

 <customer_account_login translate="label">   
  <reference name="root">  
  <action method="setTemplate"><template>page/1column.phtml</template></action>  
  </reference>   
 </customer_account_login>  


In Magento 2: Open file \Magento\Customer\view\frontend\layout\customer_account_login.xml and add layout="1column" in page tag

For Example:

 <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">  


Note: You can use other layout options like 2columns-left, 2columns-right and 3columns instead of 1column.
Note: You can use your custom module layout xml file to update layout.
How to update or change page layout in Magento2 How to update or change page layout in Magento2 Reviewed by Pranay Gondane on 6:08:00 AM Rating: 5

No comments

Free! Free!Free! Subscribe to Get Free PHP (Magento) tutorial Update in Your Inbox!!! Hurry Up!!!