• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[TUT] Adding a Facebook share button to your forum
#1
[TUT] Adding a Facebook share button to your forum

This is a tutorial on how to add a Facebook share button to the postbit, this means that it'll appear at the bottom of every post including the initial one.

Note: Any member that wishes to share the post to Facebook must have their own Facebook account.


Steps

1) Here is the button that i created, the code is below.

Code:
<script>
function fbs_click() {
u=location.href;
t=document.title;
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436' ​);
return false;
}
</script>

<style>
html .fb_share_button {
padding-top: 7px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 63px;
background:url(http://mcompute.co.uk/images/mcomputemark/facebook_share_button.png)no-repeat top right;
}
</style>

<a href="http://www.facebook.com/share.php?u=<url>" class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-decoration:none;"></a>

2) Log into your forum and go to

Admin CP > Templates & Style > Templates > *your template* > Post Bit Templates > postbit

Find:
Code:
{$post['button_email']}{$post['button_pm']}{$post['button_www']}{$post['button_rep']}

and add

Code:
{$post['button_facebook_share']}

to the end so it looks like

Code:
{$post['button_email']}{$post['button_pm']}{$post['button_www']}{$post['button_rep']}{$post['button_facebook_share']}

Save the template.

3) Now, go to Admin CP > Templates & Style > Templates > *your template* > Post Bit Templates > Add Template

Template name: postbit_facebook_share

And add the code in step 1 then save the template.


4) Download and open the file

Code:
inc/functions_post.php

And add the following

[code=php]
eval("\$post['button_facebook_share'] = \"".$templates->get("postbit_facebook_share")."\";");
[/code]

Save and re-upload the file, replacing the old one.


Further Explanation

So you've finished or.. you want to know what it looks like before you start changing things.

Live demo: http://mcompute.co.uk

postbit view
[Image: mcompute-facebook-share-1.png]

pop out view (When the button is pressed)
[Image: mcompute-facebook-share-2.png]

End result, what it looks like on Facebook.
[Image: mcompute-facebook-share-3.png]
  Reply


Messages In This Thread
[TUT] Adding a Facebook share button to your forum - by Mark - 04-12-2010, 09:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [TUT] How to add a Facebook "Like" button to your forum Mark 1 22,076 27-10-2012, 03:16 PM
Last Post: Mark
  [TUT] Adding a twitter button to your forum Mark 0 9,428 04-12-2010, 06:48 PM
Last Post: Mark

Forum Jump: