How to use local.xml to modify specific pages of Magento

Posted by Labels: at

Sometimes you may want to modify specific views of you store, instead of making changes to
all of your store views. You will mostly likely us this approach to load custom css and js, instead of loading unnecessary files on all your pages.

A. Loading style sheet and Javascript on specific view.


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

     <catalog_category_default>    
          <reference name="head">        
              <action method="addCss">            
                <stylesheet>css/bootstrap.css</stylesheet>
              </action>    
          </reference>
     </catalog_category_default>


</layout>


This will tell magento to add bootstrap.css on the <head> of the category catalog view. You may to read How to use Bootstrap on Magento.

B. Remove block on specific views of your store.


<?xml version="1.0"?>

<layout>

    <catalog_category_default>
        <remove name="footer.newsletter"/>    
    </catalog_category_default>
</layout>


This will tell Magento to remove the "footer.newsletter" block only on the category catalog view.

Wait! What if you want to add custom style sheet and javascript only to specific CMS pages? [VIEW SOLUTION HERE].

Magento is a heavy system, so do your best to use as little recourse as possible. to boost the
over roll performance of your store.  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