Magento Forum

Call custom javascript from template files
 
adityak
Member
 
Total Posts:  63
Joined:  2008-02-10
India
 

Hi I need to put a tabbed html table on my product page which uses javascript.
I call this javascript file, which I have placed in the js folder from view.phtml file.
For some reason I think it does not pick up my javascript file.
Can someone tell me, where should I place my custom javascript files and how do I reference this file from my template files?

 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

go to folder app/design/default/default/layout/ and open file page.xml. Within “default” note you can add your JS code like

<action method="addJs"><script>myfolder/my.js</script></action>

But be careful, if you update magento your changes will be overwritten. Maybe its better to create your custom design. Create folder structure
like app/design/mytheme/mytheme/layout/ and create file page.xml and copy original code from page.xml and make custom changes. Within backend
go to system->configuration choose your store and visit Design. Add your name in area “package”. Hope iam right, didnt check it

Cheers

Stefan

 
Magento Community Magento Community
Magento Community
Magento Community
 
adityak
Member
 
Total Posts:  63
Joined:  2008-02-10
India
 

Thanks Stefan,
Also I have image tags in my javascript file.
How can I reference images from within the javascript?
e.g. my images are stored in images folder

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top