local.xml for Beginners

Posted by Labels: at

What is local.xml?
local.xml is a file that helps you control how blocks are places on your pages.

What is it used for?
local.xml is mostly used to move and removing blocks around your page. It's also used to pull in your Styling sheet and JavaScript files.

How to creating local.xml file?
Always create the local.xml file inside your Theme's Layout folder.

File path: app/design/frontend/package_name/theme_name/layout/local.xml


<?xml version="1.0"?>
<layout>
    <default>

         //add all your code here

    </default>
</layout>

Local.xml basic modification?
Before adding anything, first include this xml code inside your local.xml, basically this tells Magento to apply or overwrite these modifications on all pages, hence the default tag <default>

1. How to add a CSS file?


<reference name="head">    
   <action method="addCss">        
      <stylesheet>css/style.css</stylesheet>    
   </action>
<br></reference>



2. How to add a Javascript file?


<reference name="head">    
   <action method="addItem">        
      <type>skin_js</type>        
      <name>js/jquery.js</name>        
      <params/>    
   </action>
<br></reference>


3. How to remove a block?


<remove name="paypal.partner.right.logo"/>


Next we will talk about how to move a block to a difference location and How to apply changes to specific views.

I hope this article was helpful to you, please leave your question/s on the comments section below and I will do my best to answer back.





Post a Comment

Back to Top