5/11/2010

How to add Javascript or Css file into Magento

By default there already some css and Javascript file included in the page.xml. If you want to add some more new css file then write

<action method="addCss"><stylesheet> css/Yourcss.css </stylesheet> </action>

into the page.xml which is inside Your app/design/Frontend/base/default/layout/Page.xml (in Magento 1.4.0.0 or Higher version of Magento). If you want to add a javascript then you can directly write that code into your header.Phtml file which is in the app/design/frontend/base/default/template/page/html/header.phtml .Open the file and write

<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/yourjs.js')?>"></script>

and upload/paste your js into Skin/frontend/default/default/js Folder.

No comments:

Post a Comment