Forums / Templates, Stylesheets, Page Layout / Where in the product page do I put this bit of code?

Where in the product page do I put this bit of code?

Locked

Views: 955

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
3 Aug 2010, 7:28 PM
#1
autoace avatar

autoace

Totally Zenned

Join Date:
Jun 2009
Posts:
618
Plugin Contributions:
0

Where in the product page do I put this bit of code?

I am trying to implement the Facebook 'Like' Button on my product info pages and believe I have everything in place except for one MINOR thing.... a bit confused on how to load the JavaScript SDK in my site?

I have been looking here on Facebook and it seems that the easiest way to do it is to put this bit of code:

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({appId: 'your app id', status: true, cookie: true,
             xfbml: true});
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());
</script>

in my page.

Where in the product page do I put this bit of code to load the SDK?

Thank you,
autoace

3 Aug 2010, 8:30 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Where in the product page do I put this bit of code?

autoace:

Where in the product page do I put this
Your product page is handled by tpl_product_info_display.php

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

3 Aug 2010, 8:55 PM
#3
autoace avatar

autoace

Totally Zenned

Join Date:
Jun 2009
Posts:
618
Plugin Contributions:
0

Re: Where in the product page do I put this bit of code?

Where in the tpl_product_info_display.php page?

-Or-

It doesn't matter??

Thank you,
autoace

3 Aug 2010, 9:17 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Where in the product page do I put this bit of code?

Answer: Wherever you want it to appear.

There are many blocks of HTML in the file, which you'll see shown exactly in your browser if you click View Source to see it.
Put your code between any of those sections. If it produces some visual output, then it'll show up on-screen wherever you've placed it. Move it around to where you really want it.

The sections are marked as <!-- bof: section --> and <!-- eof: section --> Best not to stick anything new "between" the bof/eof ("begin of fragment" / "end of fragment"), but rather best to put anyplace after a eof.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

3 Aug 2010, 9:19 PM
#5
autoace avatar

autoace

Totally Zenned

Join Date:
Jun 2009
Posts:
618
Plugin Contributions:
0

Re: Where in the product page do I put this bit of code?

Thank you

Thank you,
autoace

4 Aug 2010, 8:15 PM
#6
autoace avatar

autoace

Totally Zenned

Join Date:
Jun 2009
Posts:
618
Plugin Contributions:
0

Re: Where in the product page do I put this bit of code?

Can I place the js code between the head tags in the html_header.php file? (/common)?

Thank you,
autoace

4 Aug 2010, 8:25 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Where in the product page do I put this bit of code?

What exactly are you still having troubles with?

  1. You should never be putting code into html_header.php
  2. If your code must go inside the <head> tags, then you should use the auto-loading method documented in your /docs/ folder and here: http://www.zen-cart.com/wiki/index.php/Customisation_-_Templates_-_Javascript
  3. If your code actually produces output, such as the "like" button you wanted it to generate, then putting it in the <head> tags would be a bad idea, since that gives you no control over where the output is presented in the page, and may prevent it from actually being displayed at all.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

9 Aug 2010, 9:08 PM
#8
autoace avatar

autoace

Totally Zenned

Join Date:
Jun 2009
Posts:
618
Plugin Contributions:
0

Re: Where in the product page do I put this bit of code?

Thank you for the reply, very good information.

Thank you,
autoace