Is there away to add the facebook "like" button for each product? I think you need to pass the URL into the like code that I found on facebooks website.
<html>
<head>
<title>My Great Web page</title>
</head>
<body>
<iframe src="http://www.facebook.com/plugins/like.php?href=YOUR_URL"
scrolling="no" frameborder="0"
style="border:none; width:450px; height:80px"><iframe>
</body>
</html>
Any ideas?
David,
It works great. you missed the trailing </iframe>
so here's the code that works:
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php
print "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
?>" scrolling="no" frameborder="0" style="border:none; width:450px; height:80px"></iframe>
Seems like a good feature to have.
ooops - thanks! Corrected in the original post also.
Cheers,
David.
--
PriceTapestry.com
Hello David,
I am trying to apply
href=<?php print "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]; ?>
"The href entered is not recognized as a valid URL."
What am I applying wrongly in order to apply facebook like button at my website
Cheers
Steve
Hi Steve,
You'd need to use the Like button code generator with a valid URL for your site, and then convert it to be dynamic using the PHP code afterwards, so for example;
href=http://www.example.com/merchants/
Once you have the code, then convert it to exactly what you had to make it a dynamic version however I would also add urlencoding e.g:
href=<?php print urlencode("http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]); ?>
Cheers,
David.
--
PriceTapestry.com
Hi David,
could you format this iframe within default.css?
Thanks and kind regards, Boris
Hi Boris,
Sure - from the <iframe ... > code above, in place of:
style="border:none; width:450px; height:80px"
use:
class='fb_like'
And then in your CSS, with the inline styles defined as a starting point;
.fb_like {
border: none;
width: 450px;
height: 80px;
}
...and then anything else as required...
Cheers,
David.
--
PriceTapestry.com
Hi lunen,
Sure, you can normally get the page URL using
"http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]
So based on the example you found; you could simply paste the following into the end of your html/product.php:
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php
print "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
?>" scrolling="no" frameborder="0" style="border:none; width:450px; height:80px"></iframe>
Hope this helps!
Cheers,
David.
--
PriceTapestry.com