2

I am trying to add a couple of JS to Magento. I am trying to modify the "product-shop" so that it stays fixed when scrolling down. Here is a Fiddle of what I am trying to do http://jsfiddle.net/PXadg/

   `$(document).ready(function() {
        $('#summary').scrollToFixed({
            marginTop:
                $('.header').outerHeight() + 10,
            limit:
                $('.footer').offset().top -
                $('#summary').outerHeight() -
                10
        });
    });`

Can anyone help me by telling me where I need to make changes in XML or phml files so that Magento runs this scripts?

Regards,

1 Answer 1

1

Add this to your xml file

 <catalog_product_view>
         <reference name="head">
                <action method="addJs"><script>yourscript.js</script></action>
            </reference>
 </catalog_product_view>

make sure to clear cache after changing this. Also clear your browser history.

Sign up to request clarification or add additional context in comments.

5 Comments

Satish, thanks for your reply. Do I insert that in catalog.xml or do I need to create a local.xml for this? Also, where do I insert both js files, under js or skin/frontend/default/theme/js? I am new to this and this is my first time trying something like this. I really appreciate your time and help. Regards.
you need to enter this in local.xml
Hi Satish, I entered this code '<?xml version="1.0"?> <layout> <catalog_product_view> <reference name="head"> <action method="addJs"><script>jquery-scrolltofixed.js</script></action> <action method="addJs"><script>new.js</script></action> </reference> </catalog_product_view> </layout>' in a local.xml file and then added both js files to skin/frontend/default/theme/js but I didnt get it to work, any ideas? Kind regards,
as this <?xml version="1.0"?> should be already there you dont need to add second time.wher have you placed local.xml file. Was this not in use on your site.Also clear your cache.js files to be where other js files are
should go in .js folder.I suggest you do a view source and check if html has new.js. This you need to do on product view page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.