Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2007
    Posts
    72
    Plugin Contributions
    0

    Default adding product specific info into <head> tags on product pages for facebook

    Hi,

    I'm trying to add product specific code into my <head> tag so thumbnails show up when product pages are are shared on facebook. Based on following the instructions from facebook (http://wiki.developers.facebook.com/...and_Thumbnails) and this related thread (
    http://www.zen-cart.com/forum/showthread.php?t=137585
    ) I'm trying to add the following code to the page [FONT=Arial][/FONT]/includes/templates/gargyle/common/html_header.php but the URL gets chopped off before the product name.

    <link rel="image_src" href="<?php echo "http://" . $_SERVER['HTTP_HOST'] . "/shop/" . $products_image_medium; ?>"/>

    I guess that page doesn't know what
    $products_image_medium is. Does someone know how I need to edit html_header.php so that the $products_image_medium value can be populated in the header correctly, and that line will show up ONLY for product pages?

    Appreciate any help...

    thanks,
    Don

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: adding product specific info into <head> tags on product pages for facebook

    It's actually pretty simple.

    Put your html_header.php file back to how it was before you started trying this.

    Then create the following file with the following content:
    /includes/modules/pages/product_info/jscript_fbimage.php
    Code:
    <?php
      /**
       * Add "image_src" link to <head> section for current product's image
       */
      $sql = "select p.products_id, p.products_image
               from   " . TABLE_PRODUCTS . " p
               where  p.products_status = '1'
               and    p.products_id = '" . (int)$_GET['products_id'] . "'";
      $product_info = $db->Execute($sql);
    
      $products_image = $product_info->fields['products_image'];
      if ($products_image == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') {
        $products_image = PRODUCTS_IMAGE_NO_IMAGE;
      }
      if ($products_image != '') {
        require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_MAIN_PRODUCT_IMAGE));
    ?>
    <link rel="image_src" href="<?php echo HTTP_SERVER . DIR_WS_CATALOG . $products_image_medium; ?>" />
    <?php  }
    That's it!
    .

    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. #3
    Join Date
    Jun 2007
    Posts
    72
    Plugin Contributions
    0

    Default Re: adding product specific info into <head> tags on product pages for facebook

    Hi DrByte,

    Thanks for your feedback. I tried creating that file on my test server but the "image_src" code isn't showing up on the product page (link here). I'm not sure if I'm getting conflicts with another module I have installed...maybe CSS - Javascript loader (CJ Loader).

    wiki.rubikintegration.com/zencart/modules/css_javascript_loader/about

    Aside from that I'm not sure what might be wrong...I cut and pasted from your post and created the file as directed but no luck with the code in the <head> tag.

    Appreciate any thoughts you might have.

    thanks,
    Don

  4. #4
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: adding product specific info into <head> tags on product pages for facebook

    Quote Originally Posted by donplay View Post
    I tried creating that file on my test server but the "image_src" code isn't showing up on the product page (link here).
    Well, the code I posted was a copy-and-paste from after I actually tested it to confirm that it did as intended.
    Granted, I didn't test it on a site that has been as heavily modified as yours, including so-called "SEO" URLs etc.
    Quote Originally Posted by donplay View Post
    I'm not sure if I'm getting conflicts with another module I have installed...maybe CSS - Javascript loader (CJ Loader).

    wiki.rubikintegration.com/zencart/modules/css_javascript_loader/about
    Maybe. Ask *them* about that.
    .

    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.

  5. #5
    Join Date
    Jun 2007
    Posts
    72
    Plugin Contributions
    0

    Default Re: adding product specific info into <head> tags on product pages for facebook

    Hi DrByte,

    Thanks for the reply...understood. I turned off the SSU (SEO) module and the issue was still there. I'll keep digging...thanks for your help.

    -Don

  6. #6
    Join Date
    Jan 2006
    Posts
    61
    Plugin Contributions
    0

    Have a Drink Re: adding product specific info into <head> tags on product pages for facebook

    This is what I did on my site, it's the medium size images and they look good on my facebook profile.

    1- I pasted the following code before </head> on my html_header.php and saved.

    <script> function fbs_click() { u=location.href; t=document.title; window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),' sharer', 'toolbar=0, status=0, width=626, height=436'); return false; } </script>

    2- I pasted the following code after <!--eof Product description --> on my tpl_product_info_display.php and saved.

    <!--bof facebook share -->
    <link rel="image_src" href="<?php echo "http://" . $_SERVER['HTTP_HOST'] . "/" . $products_image_medium; ?>"/>
    <script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolb ar=0,status=0,width=626,height=436');return false;}</script><style> html .fb_share_link { padding:2px 0 0 20px; height:16px; background:url(http://b.static.ak.fbcdn.net/rsrc.ph...h/4273uaqa.gif) no-repeat top left; }</style><a href="http://www.facebook.com/share.php?u=<?php echo "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'];?>" onclick="return fbs_click()" target="_blank" class="fb_share_link">Share <strong><?php echo $products_name; ?></strong> on Facebook</a>
    <br class="clearBoth" />
    <!--eof facebook share -->

    3- Uploaded files to server and it worked out of the box for me, this is on a live site!! :).

    Hope that helps some one.

    Happy coding...

  7. #7
    Join Date
    May 2008
    Posts
    2
    Plugin Contributions
    0

    Default Re: adding product specific info into <head> tags on product pages for facebook

    Thank you for the valuable info. I did all this and was able to share my products on my facebook page. My main problem though is that product images do no appear in facebook. Am I missing something?

  8. #8
    Join Date
    May 2008
    Posts
    2
    Plugin Contributions
    0

    Default Re: adding product specific info into <head> tags on product pages for facebook

    For some curious reason I tried your suggestion second. And it worked for me. Thank you so much!

  9. #9
    Join Date
    Sep 2008
    Posts
    2
    Plugin Contributions
    0

    Default Re: adding product specific info into <head> tags on product pages for facebook

    This works... some of the code is invalid, but no big deal... something about ampersands etc.
    Quote Originally Posted by issy View Post
    This is what I did on my site, it's the medium size images and they look good on my facebook profile.

    1- I pasted the following code before </head> on my html_header.php and saved.

    <script> function fbs_click() { u=location.href; t=document.title; window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),' sharer', 'toolbar=0, status=0, width=626, height=436'); return false; } </script>

    2- I pasted the following code after <!--eof Product description --> on my tpl_product_info_display.php and saved.

    <!--bof facebook share -->
    <link rel="image_src" href="<?php echo "http://" . $_SERVER['HTTP_HOST'] . "/" . $products_image_medium; ?>"/>
    <script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolb ar=0,status=0,width=626,height=436');return false;}</script><style> html .fb_share_link { padding:2px 0 0 20px; height:16px; background:url(http://b.static.ak.fbcdn.net/rsrc.ph...h/4273uaqa.gif) no-repeat top left; }</style><a href="http://www.facebook.com/share.php?u=<?php echo "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'];?>" onclick="return fbs_click()" target="_blank" class="fb_share_link">Share <strong><?php echo $products_name; ?></strong> on Facebook</a>
    <br class="clearBoth" />
    <!--eof facebook share -->

    3- Uploaded files to server and it worked out of the box for me, this is on a live site!! :).

    Hope that helps some one.

    Happy coding...

  10. #10
    Join Date
    Aug 2006
    Location
    portlandish, oregon
    Posts
    799
    Plugin Contributions
    0

    Default Re: adding product specific info into <head> tags on product pages for facebook

    Hmmm, now the question is...Is there a solution for addThis, to get it to send the product image url to Facebook? I'm using addThis for all my bookmarking and it is currently just grabbing images from my left column!

    @pointsilver, validation errors regarding ampersands simply mean that you have '&' in the code that should be converted to '&amp;'

 

 

Similar Threads

  1. v151 Head's tags goes into body tag.
    By zadok.daniel in forum General Questions
    Replies: 3
    Last Post: 7 Jan 2014, 02:42 AM
  2. Replies: 8
    Last Post: 28 Feb 2012, 03:05 PM
  3. inserting links in specific product info pages
    By Sushigal in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 27 Oct 2010, 03:59 PM
  4. Unwanted space at head of product info pages
    By johnandrobin in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 15 Dec 2008, 07:14 PM
  5. Inserting forms into product Info pages
    By UnoStar in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 26 Jul 2006, 06:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR