Pages

Ads 468x60px

Tuesday, March 25, 2014

big facebook share button

This piece of code creates huge share buttons on facebook like the one below.



1st part
First put this code in the head section of your template.

<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=567348686666720";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
2nd part
Then this piece in your body section.I have noticed that if I put the css (the code between the style tags) in the skin section this causes problem with the comments box.I have no idea why.



<div id='fb-root'/>
<style>
  .fb-share-button
{
transform: scale(3.5);
-ms-transform: scale(3.5);
-webkit-transform: scale(3.5);
-o-transform: scale(3.5);
-moz-transform: scale(3.5);
transform-origin: top left;
-ms-transform-origin: top left;
-webkit-transform-origin: top left;
-moz-transform-origin: top left;
-webkit-transform-origin: top left;
}
  </style>
3rd part
The third part goes to where ever you want your button to appear.You can put the second and third at the same place.


<b:if cond='data:blog.pageType == &quot;item&quot;'>
<div class='fb-share-button' data-type='button' expr:href='data:post.canonicalUrl' expr:title='data:post.title' expr:xid='data:post.id'>
</div>
</b:if>
Tweaking
Change the numbers in pink for size.
The code in yellow changes the language of your button.


Known issues.
If you already got a facebook comments box in your blog this conlifcts with your big share/like button it may not show at all.A solution that works for me is to leave out the <script> part and the<div id='fb-root'>.This code already exists in the comments code so you don't need to paste it twice.

No comments:

Post a Comment

 

Sample text

Sample Text