magent local xml

Updating XML structure using “local.xml”

In this article, we will learn about the process of updating xml layout using Magento local xml file. As “local.xml” file is very useful to update the xml structure a coder definitely should aware of it. Also, the process is very easy to handle. Hence replace the existing “local.xml” file under your theme layout folder. However, the file will update all Magento local xml structure of specific theme.

How the Magento local xml file works?

After creating “local.xml” replace inside your theme folder. As a result, Mage always reads using the xml files. First it will search for the Magento local xml file will find the new “local.xml”. Then it will replace the layout as per latest “local.xml”.

Note: If the “local.xml” file is replaced with admin rights, the xml layout will be set as default.

 Setup:

1. To begin with make a “local.xml” inside the theme’s layout folder. The path is following (app/frontend/default/theme/layout)

2. Next insert general xml markup layout.

< ?xml version="1.0"?>
<layout version="0.1.0"></layout>

3.Finally save and replace with Magento local xml file.

Case study:

Firstly we can edit such as add or remove js from “local.xml”

Example: Code 01

<!-- Let’s remove sleight js for IE7-->
<reference name="head">
<action method="removeItem"><type>js</type><name>lib/ds-sleight.js</name><params /><if>lt IE 7</if></action>
</reference>

<!-- Instead, add belated.js from your theme’s /js folder -->
<action method="addItem"><type>skin_js</type><name>js/belated.js</name><params /><if>lt IE 7</if></action>

Secondly, we can change structure only for category page. For example: adding some js and also setting a template for website.

Example: Code 02

<default>
<reference name="right">
<remove name="catalog.compare.sidebar" />
<remove name="left.reports.product.viewed" />
<remove name="catalog.product.related" />
</reference>
</default>

3. Hence remove specific blocks from the xml structure using “remove”.

Example: Code 03

<default>
<reference name="left">
<!-- Removed the Newsletter from the left sidebar -->
<action method="unsetChild"><name>left.newsletter</name></action>
<action method="unsetChild"><name>tags_popular</name></action>

</reference>
</default>

Here are few quick tips on Mage local xml file.

In sum, the utilization of “local.xml” file to update the structure needs advance coding skills. In this circumstance a good hosting including all tech & development support is a big plus. Specially all of our hosting plans provide technical supports to our clients. Moreover the beginner plan start from just 9.99 USD per month. Hence learn more about us. Finally feel free to contact us regarding any service related questions.

Tanzia Farin Chy for Aspiration Hosting