Hello. I think it's Facebook's default but is it possible to display the count number, even if it is a zero? So it will match the twitter button as displayed in the picture attached. Many thanks and regards.

CS02

CommentFileSizeAuthor
share.jpg28.57 KBth.sigit

Comments

th.sigit’s picture

Never mind. I search over the internet and found an answer in a wordpress plugin site:

Currently there is no way to force the button to display a zero by default. Facebook's Share script controls the count display and they've set it to only appear after an item has been shared. I am exploring ways around this, as numerous users have requested this feature, but so far it appears Facebook would rather only display the count if an item has been shared.

Yet if there's some workaround for this, it'll be great :)

Edit:

I found the answer to my question on a drupal site, it is using JQuery.

Here's the link: http://www.flevour.net/blog/facebook-share-button-and-little-annoying-be....

Here's what I do:

I created a file called custom.js in my theme folder. Simply copy-and-paste the code from the above link within the file. And finally insert this line

scripts[] = custom.js

within the theme's .info file. After clearing the cache, the '0' number appears on the count button!

Yet, it is a great idea if this could be applied to the current module (I do not know how to do that).

Thanks for providing this module, and regards.

alliax’s picture

Hi CS02, I tried to use this module but it didn't work, so I reverted to adding the share button code directly in my template. I've used your link to display the 0. It works fine when there is only one button, but in the case of multiple buttons such as on tag lists or on the homepage, only the first one shows 0, the others below are normal (no above ballon)
Do you have an idea about what to change in the script?

jQuery(document).ready(function(){
  jQuery("span.fb_share_no_count").each(function(){
    jQuery(this).removeClass("fb_share_no_count");
    jQuery(".fb_share_count_inner", this).html("0");
  });
});
th.sigit’s picture

Hello alliax. I had been in a long holiday and unable to visit d.o for awhile. I am sorry I do not have the basic knowledge of jquery nor theming, etc. In the meantime, I hope you already find a solution for that problem or probably somebody else can shed some lights on it. Yet, looking at the codes (taken from the very module, even if I do not understand them), you could probably put these lines into your template.php on your theme directory. Bear with me that I'm not a coder myself and if it doesn't work I will have no clue what to do next. Regards.

/**
 * Themes facebook share button
 */
function theme_facebookshare_button($url, $size, $text) {
  $output = '<a name="fb_share" ' .
   'type="' . $size . '" share_url="' . $url . '">' .
   $text . '</a>' .
   '<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" ' .
   'type="text/javascript"></script>';
  
  return $output;
}
saveyou’s picture

You can change into this, that's it

/**
 * Themes facebook share button
 */
function theme_facebookshare_button($url, $size, $text) {
  $output = '<a name="fb_share" ' .
   'type="' . $size . '" share_url="' . $url . '">' .
   $text . '</a>' .
   '<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" ' .
   'type="text/javascript"></script>
   
   <script>
   	jQuery(document).ready(function(){
  		jQuery("span.fb_share_no_count").each(function(){
    		jQuery(this).removeClass("fb_share_no_count");
    		jQuery(".fb_share_count_inner", this).html("0");
  		});
	});
   </script>
   ';
  
  return $output;
}