Let's assume I have a company named Company
and I'm developing a magento module named Module
. What I want my module to do is simple: Add a JavaScript file to header tag of ALL pages in magento. But for some reason, it doesn't add the script in any pages.
Note: Currently I'm testing it for frontend.
Note 2::I'm using XAMPP (php 5.6, mysql 5.6, apache 2) if that's relevant.
Here is my directory tree:
Root
├───app
│ ├───code
│ │ └───local
│ │ └───Company
│ │ └───Module
│ │ └───etc
│ │ config.xml
│ │
│ ├───design
│ │ └───frontend
│ │ └───base
│ │ └───default
│ │ └───layout
│ │ module.xml
│ │
│ └───etc
│ └───modules
│ Company_Module.xml
│
└───js
└───company
module.js
Content of app\etc\modules\Company_Module.xml
:
<?xml version="1.0"?>
<config>
<modules>
<Company_Module>
<active>true</active>
<codePool>local</codePool>
</Company_Module>
</modules>
</config>
Content of app\code\local\Company\Module\etc\config.xml
:
<?xml version="1.0"?>
<config>
<modules>
<Company_Module>
<version>0.1.0</version>
</Company_Module>
</modules>
<frontend>
<layout>
<updates>
<module>
<file>module.xml</file>
</module>
</updates>
</layout>
</frontend>
</config>
Content of app\design\frontend\base\default\layout\module.xml
:
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="head">
<action method="addJs">
<script>company/module.js</script>
</action>
</reference>
</default>
</layout>
Content of js\company\module.js
:
alert('Yes!');