Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Small tutorial about local.xml in Magento

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 541
    Comment on it

    Hello Readers,

    This tutorial will guide you about local.xml file in magento. The local.xml file does not exist by default. We will have to create it in the layout folder of current theme. By Using local.xml, we can modifying the existing layout files for overriding or updating xml structure.

    Path of local.xml : It should be create in the layout folder where all other layout files exist.
    app/design/frontend/(package)/(theme)/layout.

    The idea behind local.xml is very simple: Create one file called local.xml under current theme's layout folder to override or modifying templates files.


    How to setup local.xml:

    1. Create the local.xml inside your current theme’s layout folder
    (app/frontend/default/yourtheme/layout)

    2. Add basic xml markup structure

    < ?xml version="1.0"?>

    <layout version="0.1.0">

    </layout>


    layout tag: Under this tag, all the other layout will be handles.


    Examples 1- how to add script and stylesheet in local.xml

    <default>
    
        <reference name="head">
    
            <action method="addItem">
    
                <type>skin</type>
    
                <name>js/my.js</name>
    
                <params/>
    
            </action>
    
            <action method="addItem">
    
                <type>skin</type>
    
                <name>css/styles.css</name>
    
            </action>
    
        </reference>
    
    </default>

    By using <default> tag, we can include our JS & CSS files on every page.

    addItem: This method is used to add files and target all files in the reference named head. Similarly, we can use removeItem action method to remove styles or scripts.


    Examples 2- How to remove specified blocks from the layout.
     

    <default>
    
    <reference name="left">
    
    <action method="unsetChild"><name>left.newsletter</name></action>
    
    <action method="unsetChild"><name>tags_popular</name></action>
    
    </reference>
    
    </default>


    unsetChild: This action method is used to remove specific blocks in your layout:

    One point to be remember in this guide: Magento will always look for a file called local.xml (if exist) in the currently configured theme.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: