View Single Post
  #13  
Old June 20th, 2012, 12:49 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

If you want to add a Like button to each product in a Category, you can add the following code between the [product.each] and [product.end] tags in your Product list module:

HTML Code:
<iframe src="//www.facebook.com/plugins/like.php?href=<?php echo urlencode('http://' . $_SERVER['HTTP_HOST'] . '/' . $product->site_link); ?>&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=80" 
scrolling="no" 
frameborder="0" 
style="border:none; overflow:hidden; width:450px; height:80px;" 
allowTransparency="true">
</iframe>
If you are having problems with that, you may need to check this line:

Code:
<?php echo urlencode('http://' . $_SERVER['HTTP_HOST'] . '/' . $product->site_link); ?>
Let's break it down:
  • <?php echo - Open the PHP statement. Don't change.
  • urlencode( - We run the entire URL through a built in PHP URL encoder.
  • 'http://' . - This is the beginning of the URL. If you are using an SSL connection, it should be 'https://' .
  • $_SERVER['HTTP_HOST'] . - This is your site's domain name. If you need to change your domain name, you do that here.
  • '/' . - This is the forward slash / between your domain name and the beginning of the path in the URL.
  • $product->site_link - This is the path to the product page.
  • ) - Close the urlencode( function.
  • ; ?> - Close the PHP statement. Don't change.