Page 1 of 12 12311 ... LastLast
Results 1 to 10 of 115
  1. #1
    Join Date
    Mar 2009
    Posts
    102
    Plugin Contributions
    0

    Default Facebook "Like" button on every product page?

    Hi
    I've added AddThis on every product page (which was pretty easy), but I also want to add the new "Like button" from Facebook. You simply put a single iframe line where you want, and you're good to go.

    Read more: http://developers.facebook.com/docs/...e/plugins/like

    Here's the example code:

    Code:
    <iframe src="http://www.facebook.com/widgets/like.php?href=http://example.com"
            scrolling="no" frameborder="0"
            style="border:none; width:450px; height:80px"></iframe>
    How do I get the href part to point to the page from which the visitor clicked? like href=http://www.mysite.com/index.php?main_page=product_info&cPath=543&products_id=4 without having to hard code it?

  2. #2
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Facebook "Like button" on every product page

    Something like:

    Code:
    <?php
    echo zen_href_link(zen_get_info_page((int)$_GET['products_id']),'cPath= '.(int)$_GET['cPath'].' &products_id=' . (int)$_GET['products_id']);
    ?>
    haven't tested this but it should work

  3. #3
    Join Date
    Jan 2007
    Posts
    66
    Plugin Contributions
    0

    Default Re: Facebook "Like" button on every product page?

    Does that line of code go where the iframe ref is?

  4. #4
    Join Date
    Jan 2007
    Posts
    66
    Plugin Contributions
    0

    Default Re: Facebook "Like" button on every product page?

    I have both the iframe and the piece of code that niccol added, but can not seem to get it right. I have added the code prior to the iframe...nothing, the code as the ref in the iframe...nothing!.

    Not really sure how to put this together to make it work.

  5. #5
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Facebook "Like" button on every product page?

    On a product_info page that code will produce this in the html:

    Code:
    http://domain.com/index.php?main_page=product_info&cPath= 65 &products_id=181
    Or whatever the details are. It will produce that wherever you put it as long as it is not already in <?php ?> tags in which case you'd need to remove the ones in my code.

    So you could just put that code somewhere at the top of the page and you will see what it is outputing.

    What you actually want to do is this:

    Code:
    <iframe src="http://www.facebook.com/widgets/like.php?href=<?php echo zen_href_link(zen_get_info_page((int)$_GET['products_id']),'cPath= '.(int)$_GET['cPath'].' &products_id=' . (int)$_GET['products_id']); ?>"
            scrolling="no" frameborder="0"
            style="border:none; width:450px; height:80px"></iframe>
    But looking at it again I am not sure that the whole plan is going to work in that I am not sure the system will deal with the dynamic URL anyway. What that means is that I am not sure how the system will deal with the bit after the question mark. It might or it might not.

  6. #6
    Join Date
    Jan 2007
    Posts
    66
    Plugin Contributions
    0

    Default Re: Facebook "Like" button on every product page?

    Nick,

    Thank you so much that worked !!!!

  7. #7
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Facebook "Like" button on every product page?

    Splendid. Glad it played ball. Well done!

  8. #8
    Join Date
    Mar 2009
    Posts
    102
    Plugin Contributions
    0

    Default Re: Facebook "Like" button on every product page?

    Quote Originally Posted by niccol View Post
    On a product_info page that code will produce this in the html:

    Code:
    http://domain.com/index.php?main_page=product_info&cPath= 65 &products_id=181
    Or whatever the details are. It will produce that wherever you put it as long as it is not already in <?php ?> tags in which case you'd need to remove the ones in my code.

    So you could just put that code somewhere at the top of the page and you will see what it is outputing.

    What you actually want to do is this:

    Code:
    <iframe src="http://www.facebook.com/widgets/like.php?href=<?php echo zen_href_link(zen_get_info_page((int)$_GET['products_id']),'cPath= '.(int)$_GET['cPath'].' &products_id=' . (int)$_GET['products_id']); ?>"
            scrolling="no" frameborder="0"
            style="border:none; width:450px; height:80px"></iframe>
    But looking at it again I am not sure that the whole plan is going to work in that I am not sure the system will deal with the dynamic URL anyway. What that means is that I am not sure how the system will deal with the bit after the question mark. It might or it might not.
    Excellent, it works! Now I only have to position it...

    For reference (if someone else want to do it), the file you're looking for is includes --> templates --> YOUR TEMPLATE --> template --> tpl_product_info_display.php.

  9. #9
    Join Date
    Jun 2006
    Posts
    777
    Plugin Contributions
    0

    Default Re: Facebook "Like" button on every product page?

    Ver 1.3.8a

    Sorry if a dumb question but does this code need to be added to every product page? Or is there a PHP file that will insert into every product page?

  10. #10
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Facebook "Like" button on every product page?

    If you edit the file tpl_product_info_display.php then those edits will appear in each product info page (except if you are using different product types)

 

 
Page 1 of 12 12311 ... LastLast

Similar Threads

  1. Facebook "Like/Share" Plugin - Using OG info for each product?
    By rubiconpeak in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 14 Oct 2012, 12:08 AM
  2. Facebook "Like" Button on each product page - where to add FB details?
    By Yaro in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 6 Jun 2012, 11:26 AM
  3. Facebook "Like" button
    By wilson_li in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 28 Jul 2011, 08:29 PM
  4. Facebook "LIKE" button.
    By Tantirx in forum General Questions
    Replies: 7
    Last Post: 28 Apr 2011, 05:42 AM
  5. Replies: 26
    Last Post: 19 Feb 2010, 02:56 AM

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