This mod adds a facebook like button to each topic.
Tested with phpBB 3 (But there is no version dependent code, so it will work on all versions, if someone tests in other versions, please post the errors/success messages here)
Screenshot:
Steps:
1. OPEN FORUM_ROOT/includes/functions.php
2. FIND THE BLOCK:
--------------------
// Send a proper content-language to the output
$user_lang = $user->lang['USER_LANG'];
if (strpos($user_lang, '-x-') !== false)
{
$user_lang = substr($user_lang, 0, strpos($user_lang, '-x-'));
}
--------------------
3. ADD BELOW:
--------------------
//Facebook like hack by Sriram.A.S. (sriramdasty7@gmail.com)
$pieces=explode("?",$user->page['page']);
if($pieces[0]=="viewtopic.php")
{
$curr_url=generate_board_url() .'/'. $pieces[0]."?";
$pieces=explode("&",$pieces[1]);
$flag_tmp=0;
foreach($pieces as $temp_x)
{
if(substr($temp_x,0,2)=="f=" && $flag_tmp==0)
{
$curr_url=$curr_url.$temp_x;
$flag_tmp=1;
break;
}
}
foreach($pieces as $temp_x)
{
if(substr($temp_x,0,2)=="t=" && $flag_tmp==1)
{
$curr_url=$curr_url."&".$temp_x;
break;
}
}
}
--------------------
4. In the same file, FIND
--------------------
'SITE_LOGO_IMG' => $user->img('site_logo'),
--------------------
5. ADD BELOW
--------------------
'CURRENT_URL' => $curr_url,
--------------------
6. SAVE file with changes
7. OPEN FORUM_ROOT/styles/{YOUR_TEMPLATE}/template/viewtopic_body.html
8. FIND FIRST OCCURANCE OF THE BLOCK
--------------------
<div class="buttons">
<!-- IF not S_IS_BOT and S_DISPLAY_REPLY_INFO -->
--------------------
8. ADD BEFORE
--------------------
<div align="right">
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="{CURRENT_URL}" show_faces="true" width="450"></fb:like></div>
--------------------
9. If you want the like button also in bottom, fine the second occurance of the block and also add accordingly
10. SAVE file with changes
11. Now, Login to Administration Control Panel from frontend and in the main page,
Resynchronise or reset statistics-->Purge the cache-->Run now
If you face any problems, post here.
Tested with phpBB 3 (But there is no version dependent code, so it will work on all versions, if someone tests in other versions, please post the errors/success messages here)
Screenshot:
Steps:
1. OPEN FORUM_ROOT/includes/functions.php
2. FIND THE BLOCK:
--------------------
// Send a proper content-language to the output
$user_lang = $user->lang['USER_LANG'];
if (strpos($user_lang, '-x-') !== false)
{
$user_lang = substr($user_lang, 0, strpos($user_lang, '-x-'));
}
--------------------
3. ADD BELOW:
--------------------
//Facebook like hack by Sriram.A.S. (sriramdasty7@gmail.com)
$pieces=explode("?",$user->page['page']);
if($pieces[0]=="viewtopic.php")
{
$curr_url=generate_board_url() .'/'. $pieces[0]."?";
$pieces=explode("&",$pieces[1]);
$flag_tmp=0;
foreach($pieces as $temp_x)
{
if(substr($temp_x,0,2)=="f=" && $flag_tmp==0)
{
$curr_url=$curr_url.$temp_x;
$flag_tmp=1;
break;
}
}
foreach($pieces as $temp_x)
{
if(substr($temp_x,0,2)=="t=" && $flag_tmp==1)
{
$curr_url=$curr_url."&".$temp_x;
break;
}
}
}
--------------------
4. In the same file, FIND
--------------------
'SITE_LOGO_IMG' => $user->img('site_logo'),
--------------------
5. ADD BELOW
--------------------
'CURRENT_URL' => $curr_url,
--------------------
6. SAVE file with changes
7. OPEN FORUM_ROOT/styles/{YOUR_TEMPLATE}/template/viewtopic_body.html
8. FIND FIRST OCCURANCE OF THE BLOCK
--------------------
<div class="buttons">
<!-- IF not S_IS_BOT and S_DISPLAY_REPLY_INFO -->
--------------------
8. ADD BEFORE
--------------------
<div align="right">
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="{CURRENT_URL}" show_faces="true" width="450"></fb:like></div>
--------------------
9. If you want the like button also in bottom, fine the second occurance of the block and also add accordingly
10. SAVE file with changes
11. Now, Login to Administration Control Panel from frontend and in the main page,
Resynchronise or reset statistics-->Purge the cache-->Run now
If you face any problems, post here.
Good work. It works fine and easy.
ReplyDeleteHi. I have a question: when you "like" a topic, as it appears in facebook? I used a mod that, when I "like" a topic, the topic title does not appear in facebook.
ReplyDeleteYeah, its because we pass only the URL to fb for like, and fb does the rest, anyways, nice suggestion, i will try to find a way to post topic name properly in fb. I will check that and upload new mod soon. Thanks
ReplyDeleteI can't find:
ReplyDelete// Send a proper content-language to the output
$user_lang = $user->lang['USER_LANG'];
if (strpos($user_lang, '-x-') !== false)
{
$user_lang = substr($user_lang, 0, strpos($user_lang, '-x-'));
}
in functions.php pls.
Hello friend. Im using grunge template, and i did everything you described. And nothing happens. It doesn't give me an error but nothing shows. And im sure that i did it right. Please help me.
ReplyDeleteTotally agree with your suggestion... Very nice post and good information here... Thanks for posting that....
ReplyDeleteDo you need a like button image for this ?
ReplyDeleteIve done the file edits, but when i click like, nothing is appearing on my facebook wall?
ReplyDeleteHi John, No image is required for this, could you plz give me a link to your phpBB forum here, I removed my phpBB setup, we will see whats the problem!!
ReplyDeleteThanks
Great job, this works as expected.
ReplyDeleteJust one note that I found when trying the Facebook like button. If you are not currently signed into Facebook, and then you are on the Forum and use the "Like" button, you are taken to Facebook to log in, then once you are logged in, you still need to go back to your post in the forum to "like" it on Facebook.
Totally agree with your suggestion... Very nice post and good information here... Thanks for posting that....
ReplyDeleteHi,
ReplyDelete"Yeah, its because we pass only the URL to fb for like, and fb does the rest, anyways, nice suggestion, i will try to find a way to post topic name properly in fb. I will check that and upload new mod soon. Thanks:"
Have you got any idea for this yet?
Also is there any way a user can click the like button even if he not logged into facebook?
Ahh forgot to say, thanks for the good post!!!
I cant get access to my forum anymore. How can i fix it, i did as you suggested
ReplyDeleteMay I know what is the error. You can revert all changes, may be you accidentally missed something. Anyways, if you need help, you can mail me too. Not to worry.
ReplyDelete