you need to add the layout update section to the modules configuration file. based on what you said, you will need something like this in your layout file:
<?xml version="1.0"?>
<layout version="0.1.0">
<catalog_product_view>
<reference name="head">
<action method="addJs"><script>yourscript.js</script></action>
</reference>
</catalog_product_view>
<catalog_category_view>
<reference name="head">
<action method="addJs"><script>yourscript.js</script></action>
</reference>
</catalog_category_view>
</layout>
Then, in your modules configuration file, you need something like:
<frontend>
<layout>
<updates>
<yourmodule>
<file>yourlayout.xml</file>
</yourmodule>
</updates>
</layout>
</frontend>
This assumes yourscript.js is in the js root directory. Obviously, you do not want to post it here, so do what Jonathan advised and used:
<action method="addItem"><type>skin_js</type><name>path/file.js</name></action>
and put your js in the theme skins folder.
Good luck
source
share