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?
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 :smile:
Re: Facebook "Like" button on every product page?
Does that line of code go where the iframe ref is?
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.
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.
Re: Facebook "Like" button on every product page?
Nick,
Thank you so much that worked !!!!
Re: Facebook "Like" button on every product page?
Splendid. Glad it played ball. Well done!
Re: Facebook "Like" button on every product page?
Quote:
Originally Posted by
niccol
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.
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?
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)