Share on Facebook

Contrib type: 
Code/CSS Snippet
Status: 
Complete and working
Moderation: 
Awaiting moderation

Downloads


Compatibility: 
Ubercart 1.x
Compatibility: 
Ubercart 2.x

This is just a few lines of code that you can place in your product tpl.php files to create a "Share on Facebook" link. Facebook makes a link readily available on their website, but pages with that link inserted do not validate. I am running D6 but I see no reason why this wouldn't work on D5.

<?php $your_current_url = "http://" .$_SERVER['HTTP_HOST'] .$_SERVER['REQUEST_URI']; ?>
<?php print '<a rel="nofollow" href="http://www.facebook.com/sharer.php?u=' . $your_current_url .'&amp;t=' . $node->title . '" title="Share this product on Facebook">Share on Facebook</a>'?></p>

One note, this will only pass the node title (generally the name of the product) to Facebook. If you want to include your site's name, you can do it right before the $node->title variable. For example:

<?php
$your_current_url
= "http://" .$_SERVER['HTTP_HOST'] .$_SERVER['REQUEST_URI'];
?>
<?php
print '<a rel="nofollow" href="http://www.facebook.com/sharer.php?u=' . $your_current_url .'&amp;t=YOURSITESNAME - ' . $node->title . '" title="Share this product on Facebook">Share on Facebook</a>'
?>
torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4111
Re: Share on Facebook

Might also check out the ShareThis module: http://drupal.org/project/sharethis

Thanks for the snippet Smiling

--
Help directly fund development: Donate via PayPal!

mimetic2's picture
Offline
Joined: 08/07/2007
Juice: 478
Re: Re: Share on Facebook

Or you could also check out the service links module

http://drupal.org/project/service_links

has more than just FB

ragavendra_bn's picture
Offline
Joined: 01/10/2009
Juice: 68
Re: Share on Facebook

There is addtoany drupal module also.

I was looking for a module which could actually share the product image may be with title or description also on facebook...........