Share on Facebook

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


Ubercart 1.x
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="' . $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:

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

Might also check out the ShareThis module:

Thanks for the snippet Smiling

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

Or you could also check out the service links module

has more than just FB

ragavendra_bn's picture
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...........