Switching a Magento Page to a Different Layout Template

Switching a Magento Page to a Different Layout Template

Every page in Magento 1 is wrapped in a root template such as one column, two columns with a left sidebar, or an empty shell. You can swap that template for any page using layout XML instead of editing core files.

The layout update

Target the root block and call setTemplate with the template you want. This example uses the empty layout:

<reference name="root">
 <action method="setTemplate"><template>page/empty.phtml</template></action>
</reference>

Applying it to one page only

Wrap the same instruction in the layout handle for the page you want to change. Here the shopping cart is moved onto the two-column, left-sidebar template:

<checkout_cart_index translate="label"> 
  <reference name="root"> 
     <action method="setTemplate">
        <template>page/2columns-left.phtml</template>
     </action> 
  </reference> 
</checkout_cart_index>

Place the update in your theme’s local.xml or in a module layout file, then clear the cache. The same pattern works for category, product and CMS handles.

Need a second pair of eyes on this? Our team handles Magento development every week. See how we can help.

Keep reading

Related articles

All articles

Need a hand?

Stuck on something similar?
We can fix it with you.

Send us the problem. A senior developer reads every message and replies within one working day.