Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Magento Extension
 
Rachna Shah
Jr. Member
 
Total Posts:  7
Joined:  2009-05-04
 

I am creating Extension in which I need to attach JS file. Can I attach .js file? how can I attach? also where I have to place this JS in extension format.

Please help me as soon as possible.

 
Magento Community Magento Community
Magento Community
Magento Community
 
G_Mehta
Guru
 
Avatar
Total Posts:  418
Joined:  2010-01-27
India
 

Whenever you made extension just make practice to define all realted files (like, library’s, JS) into your layout file..
Put JS files into JS folder, libarary’s into “lib” folder.

To illustrate: here, i add Jquery’s files into my layout file, with this method we can also avoid conflication....... like say for magento, prototype JS and Jquery.  wink

<catalog_category_default>
        <
reference name="head">
            <
action method="addItem"><type>js</type><name>jquery/jquery-1.6.4.min.js</name></action>
            <
action method="addItem"><type>skin_js</type><name>js/fancybox/jquery.fancybox-1.3.4.js</name></action>
            <
action method="addItem"><type>skin_js</type><name>js/fancybox/jquery.easing-1.3.pack.js</name></action>
            <
action method="addItem"><type>skin_js</type><name>js/fancybox/jquery.mousewheel-3.0.4.pack.js</name></action>
            <
action method="addItem"><type>js</type><name>jquery/noconflict.js</name></action>
            <
action method="addCss"><stylesheet>js/fancybox/jquery.fancybox-1.3.4.css</stylesheet></action>
        </
reference>
        <
reference name='product_list'>
            <
action method='setTemplate'><template>ajax/catalog/product/view/list.phtml</template></action>
        </
reference>
    </
catalog_category_default>

Hope it will helps you… Cheers!

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