Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5


[TUT] How to add a Facebook "Like" button to your forum
04-12-2010, 09:17 PM (This post was last modified: 27-10-2012 03:14 PM by howtothings.)
Post: #1
[TUT] How to add a Facebook "Like" button to your forum
[TUT] How to add a Facebook "Like" button to your forum

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

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


Steps

1) Go to http://developers.facebook.com/docs/refe...ugins/like and design your button, the code will be similar to below. The code below is what i used.

[code=html]
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like layout="button_count" show_faces="false" width="450"></fb:like>
[/code]

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_like']}

to the end so it looks like

Code:
{$post['button_email']}{$post['button_pm']}{$post['button_www']}{$post['button_rep']}{$post['button_facebook_like']}
Save the template.

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

Template name: postbit_facebook_like

Add the folling code into the large white text area

[code=html]
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like layout="button_count" show_faces="false" width="450"></fb:like>
[/code]

Save the template.


4) Download and open the file

Code:
inc/functions_post.php

And add the following

[code=php]
eval("\$post['button_facebook_like'] = \"".$templates->get("postbit_facebook_like")."\";");
[/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 (no likes)
[Image: mcompute-facebook-like-1.png]

postbit view (3 likes)
[Image: mcompute-facebook-like-2.png]

What it looks like on Facebook
[Image: mcompute-facebook-like-3.png]



You can add the button anywhere really, even the showthread template adding the code

Code:
<!-- Facebook like button (start) -->
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>

<style>
.facebooklikestyle {
float: left;
padding-right:1400px;
}
</style>

<fb:like class="facebooklikestyle" layout="button_count" show_faces="false" width="450"></fb:like>
<!-- Facebook like button (end) -->

Just under

Code:
<body>
    {$header}
    {$pollbox}

for example.


[Image: engrish25.png]
Reply
27-07-2012, 04:20 PM
Post: #2
RE: [TUT] How to add a Facebook "Like" button to your forum
It doesn't work as it should for me.

The like buttons for posts are all for the same url, which is for the thread, so my users can only like the thread, not single posts.
Reply
26-10-2012, 07:32 PM
Post: #3
RE: [TUT] How to add a Facebook "Like" button to your forum
Save and re-upload the file, replacing the old one.??
where is the file?
Reply
27-10-2012, 03:16 PM
Post: #4
RE: [TUT] How to add a Facebook "Like" button to your forum
(26-10-2012 07:32 PM)tamnguyen949 Wrote:  Save and re-upload the file, replacing the old one.??
where is the file?

Oops... messed up the thread layout a bit and had that all in one coding [], the file is in /public_html/inc/ and is called functions_post.php


[Image: engrish25.png]
Reply



Forum Jump:


User(s) browsing this thread: 1 Guest(s)