Page 1 of 2 12 LastLast
Results 1 to 10 of 115

Hybrid View

  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
    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.

  8. #8
    Join Date
    Nov 2009
    Location
    Aurora, IN
    Posts
    37
    Plugin Contributions
    0

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

    It puts the Like button there fine, and says that I "Like" it when I click it, but then it gives me an error message, and when I click on it, it says, "The page at http://mysite.com/index.php?main_page=product_info could not be reached."

    Any ideas how to fix that?


    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.

  9. #9
    Join Date
    Jun 2008
    Posts
    61
    Plugin Contributions
    1

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

    Quote Originally Posted by niccol View Post

    ...

    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.
    Yup, seems to work only if the site is using SEF urls.

    The default URLs with the character "&" in the url will cause error on the Facebook side.

    Any idea how to overcome this (without installing the SEF add-on)? Thanks.

  10. #10
    Join Date
    Feb 2010
    Posts
    13
    Plugin Contributions
    0

    Default Facebook like button

    Hi,

    Does anyone know how I can put a facebook 'like' button in my shop. Ive tried Google-ing it, but none of these solutions seem to work, and also entering the code myself doesn't work.


    Thanks.

 

 
Page 1 of 2 12 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