Adding a “Like” Button to phpbb

I want to run phpbb as a bulletin board system on my business web site, and a question came up recently about adding a “Like” button to each post.  I was a bit surprised that phpbb doesn’t seem to have this function already built in.  But I was even more surprised when I could not find a user-modification that worked like I wanted, even after searching google for quite some time.

So I thought I would make something myself.  I mean, how hard could it be?  phpbb is just php and mysql.  Turns out it wasn’t easy, which I suppose I should expect when working on OPC (other people’s code).  There’s just no way to get to know all the details of OPC, so you have to just plug away and make educated guesses and hope for the best.  That’s what I did.

But first, I tried this mod which gave me some insight as to how phpbb modifications are created and documented.  Turns out the “modx” format is basically a list of edit instructions, i.e. “find this line, then insert this line before or after”.  Not rocket science, but probably too difficult for a non-programmer.

Turns out that particular modx did not work, and I couldn’t figure out why.  In fact, when I made changes to any of the php code or html templates, the changes often didn’t seem to affect the running bulletin board.  Very strange!  Then I learned about phpbb caching.  Looks like phpbb works from files in the ./cache directory instead of the main directories.  That means the program decides when (if?) it has to copy or refresh the cache files.  That makes it difficult to develop or even implement modx updates.

But google helped me find the phpbb option below, which tells it to check for file updates every time a page is loaded.  This works well during development, but don’t forget to turn it off for better performance when you are finished working.

  • On the Admin Control Panel (ACP) at the bottom left click Load Settings
  • Find Recompile stale style components and set it to Yes

Now when I make a change to php or html or css, the change goes into effect immediately.  Well… close to immediately.  It seemed that for some things (graphics?) I had to refresh the browser at least twice to get the changes to occur.  Very odd.

Required Modifications

Anyway, here are my notes for adding a Like button to the prosilver theme that comes with phpbb 3.0.11:

Create a New Mysql Table

We’ll need a place to store the Like information, so let’s make a mysql table.  Just run this SQL through phpmyadmin or the mysql command-line process for your database name:

create table phpbb_likes (
  likes_key varchar(100), primary key(likes_key),
  likes_count int, 
  likes_who text

Add One New File

Include the following code as new file ./like.php which will handle the process of bumping up the like count for a particular post:

 define('IN_PHPBB', true);
 $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
 $phpEx = substr(strrchr(__FILE__, '.'), 1);
 include($phpbb_root_path . 'common.' . $phpEx);
 include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
 include($phpbb_root_path . 'includes/bbcode.' . $phpEx);

 // Start session management

 // Initial var setup
 $forum_id = request_var('f', 0);
 $topic_id = request_var('t', 0);
 $post_id = request_var('p', 0);

 $likes_user = $user->data['username'];

 $likes_key = $forum_id.'_'.$topic_id.'_'.$post_id;
 $likes_sql = "select * from phpbb_likes where likes_key='$likes_key'";
 $likes_result = $db->sql_query($likes_sql);
 $likes_row = $db->sql_fetchrow($likes_result);
 $likes_who = $likes_row['likes_who'];
 $likes_count = $likes_row['likes_count'];

 $split = explode(' ',$likes_who);

 if (!(array_search($likes_user,$split) !== FALSE))
   $likes_who .= " $likes_user";
   if ($likes_count)
     $likes_sql = "update phpbb_likes set likes_who='$likes_who',likes_count='$likes_count' where likes_key='$likes_key' limit 1";
     $likes_result = $db->sql_query($likes_sql);
     $likes_count = 1;
     $likes_sql = "insert into phpbb_likes set likes_key='$likes_key',likes_who='$likes_who',likes_count='$likes_count'";
     $likes_result = $db->sql_query($likes_sql);

 $likes_back = str_replace('~','&',$_GET['back']);
 header("Location: viewtopic.php?$likes_back");

Modify existing file ./viewtopic.php

Find the following line:

'QUOTE_IMG'  => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE'),

Add this line after it:

'LIKE_IMG'  => $user->img('icon_post_like', 'LIKE'),

Find the following line:

$postrow = array(

Add these 11 lines before it:

$likes_key = $forum_id.'_'.$topic_id.'_'.$row['post_id']; 
$likes_sql = "SELECT * FROM phpbb_likes where likes_key='$likes_key'"; 
$likes_result = $db->sql_query($likes_sql); 
$likes_row = $db->sql_fetchrow($likes_result); 
$likes_count = $likes_row['likes_count']; 
$likes_who = $likes_row['likes_who']; 
if (!$likes_count) $likes_text = ''; 
if ($likes_count == 1) $likes_text = "<a href='#' title='$likes_who'>1 Like</a>"; 
if ($likes_count > 1) $likes_text = "<a href='#' title='$likes_who'>$likes_count Likes</a>"; 
$likes_back = str_replace('&','~',$_SERVER['QUERY_STRING']); 
$likes_link = "f=$forum_id&amp;t=$topic_id&amp;p={$row['post_id']}&amp;back=$likes_back";

Find the following line

'U_QUOTE'  => ($auth->acl_get('f_reply', $forum_id)) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=quote&amp;f=$forum_id&amp;p={$row['post_id']}") : '',

Add the following 2 lines after it:

'U_LIKE' => ($auth->acl_get('f_reply', $forum_id)) ? append_sid("{$phpbb_root_path}like.$phpEx", $likes_link) : '',
'U_LIKE_TEXT' => $likes_text,

Modify existing file ./language/en/common.php

Find the following line:

'LEGEND'   => 'Legend',

Add the following line after it:

'LIKE' => 'Like this post',

Modify existing file ./styles/prosilver/template/viewtopic_body.html

Find the following line (there are two – find the first one)

<ul class="profile-icons">

Add this line after it:

<!-- IF postrow.U_LIKE --><li>{postrow.U_LIKE_TEXT}</li><li class="like-icon"><a href="{postrow.U_LIKE}" title="{L_LIKE}"><span>{L_LIKE}</span></a></li><!-- ENDIF -->

Modify existing file ./styles/prosilver/theme/buttons.css

Find the following line:

ul.profile-icons li.quote-icon    { width: {IMG_ICON_POST_QUOTE_WIDTH}px; height: {IMG_ICON_POST_QUOTE_HEIGHT}px; }

Add this line after it:

ul.profile-icons    { width: {IMG_ICON_POST_QUOTE_WIDTH}px; height: {IMG_ICON_POST_QUOTE_HEIGHT}px; }

Find the following line:

ul.profile-icons li.quote-icon    { margin: 0 0 0 10px; }

Add this line after it:

ul.profile-icons    { margin: 0 0 0 10px; }

Modify existing file ./styles/prosilver/theme/colours.css

Find the following line:

quote-icon, .quote-icon a        { background-image: url("{IMG_ICON_POST_QUOTE_SRC}"); }

Add the following line after it.  Note:  I don’t know how to create IMG_ICON… constants in phpbb, so I hard coded the gif file location as shown below:

.like-icon, .like-icon a        { background-image: url("/bb/styles/prosilver/imageset/en/icon_post_like.gif"); }

Download the following files

… to ./styles/prosilver/imageset/en/icon_post_like.gif
… and optionally, icon_post.png (if you want to edit the graphic yourself)

icon_post_like icon_post_like

And I put the modified files in this zip file if those might help.  But remember, even a small change to the phpbb version could cause these not to work.  I guess that’s why people tend to make their own edits.

Now for the Hard Part

You thought the hard part was over?  The changes above are nothing compared to debugging the problems you may have just caused.  Oops… I forgot to mention that you should first make a backup of any files that need to be altered.  Too late?

When you go look at a post you should see a new “Like” button, shown here to the left of the Edit button:


When you click on one of the Like buttons, the like.php routine should run, which creates an entry in phpbb_likes and sets the counter to 1, which is then displayed as:


If you click the Like button again, nothing happens – you can’t Like more than once, of course.  But if someone else clicks it, the number bumps up.  You can hold the mouse over the text to see the userids who Like the post, such as shown below:


89 thoughts on “Adding a “Like” Button to phpbb

  1. Hi. Thanks for your work. :-)

    Would you have an archive of modified files? I’ve tried to follow this guide but so far am stuck as some CSS fles gets corrupted and the Like button only comes up as a text line but not a real button. I’ve put it through Safari and Firefox error consoles and it tells me a CSS file has mime type text/html. It also isn’t exactly clear as it doesn’t show me the source so I can look at it. I take it this is the devil of using scripts since they are on fly generated and not read from a file.

    I sett up a PHP qiuickinstall which works fine if I don’t mod the files.

    I’ve found things like some dbal error on line 754 but that is beyond my control. Seems there is an error where PHP generates HTML for telling the error which the browser thinks should be CSS or something like that. :-)

    Looking at the code it traps some error but I have no idea why ii errors. Since the code is original source from what I can tell. Looks like I need a program that can check web files as the browser loads them or indeed a HTML and CSS checker that can work over the LAN.

    Would appreciate any clues or files. ;-)

  2. Hi Damien,

    Sorry I probably won’t be much help. The way I tend to solve issues (when I don’t know much about the software) is basically trial and error. Often many trials and errors :) So I’d suggest starting with your good, working system (no mods) and then introduce the modifications a bit at a time and try to find which one and where the error is occurring. I copied the modified files to a zip file if that helps at all:


    • Hi Tom. Yes I know about trial and errors. Currently running trials all ending up in errors. ;-)

      Thanks for the file mods. I’ll use these as my base files for testing. Still, a bit of C&P (copy & paste) from the blog into the destined file, was still a lot easier than entering in all those BASIC sources in the 80′s. :-D

      I suspected it was the CSS files with the path to the Like GIF failing but I’;m sure the paths I put in place would have got it. In any case I even cloned the QUOTE image in its place and the CSS still broke with no extyra quote button in place of the like.

      I’m sure it is some CSS issue as the forum looks as if there is no CSS or it has a plain vertical layout fro man old browser without CSS support. :-)

  3. Tom, I’m still getting a few issues with this (though your groundwork is excellent). I am asking permission to repost this onto the phpbb3 Community Forum to see if we can get a working MOD out of this.

    Of course Credit will be given to yourself.


  4. Hello Tom. Happy New Year!
    This is a very nice “mod” with only a few edits. Congratulations!
    I am facing this “error” when I click on the like button.
    session_begin(); $auth->acl($user->data); // Initial var setup $forum_id = request_var(‘f’, 0); $topic_id = request_var(‘t’, 0); $post_id = request_var(‘p’, 0); $likes_user = $user->data['username']; $likes_key = $forum_id.’_’.$topic_id.’_’.$post_id; $likes_sql = “select * from alsth_likes where likes_key=’$likes_key’”; $likes_result = $db->sql_query($likes_sql); $likes_row = $db->sql_fetchrow($likes_result); $likes_who = $likes_row['likes_who']; $likes_count = $likes_row['likes_count']; $split = explode(‘ ‘,$likes_who); if (!(array_search($likes_user,$split) !== FALSE)) { $likes_who .= ” $likes_user”; if ($likes_count) { $likes_count++; $likes_sql = “update alsth_likes set likes_who=’$likes_who’,likes_count=’$likes_count’ where likes_key=’$likes_key’ limit 1″; $likes_result = $db->sql_query($likes_sql); } else { $likes_count = 1; $likes_sql = “insert into alsth_likes set likes_key=’$likes_key’,likes_who=’$likes_who’,likes_count=’$likes_count’”; $likes_result = $db->sql_query($likes_sql); } } $likes_back = str_replace(‘~’,'&’,$_GET['back']); header(“Location: viewtopic.php?$likes_back”); exit; ?>

    Do you have any idea what is this? Could you give me an advice how to solve it?
    Thank you.

    • If you’re seeing all that text on your browser screen, perhaps your system is setup to require <?php instead of the short form <? when beginning a php section. Just a guess though.

  5. Yes, I am seeing this right after I pressed the like button. As I understand it, it has to with like.php
    I am testing it in my pc using wamp server. Could this couse the problem? PHP version is 5.4.12
    Can you please explain what do you mean when you told me that “my system is setup to require”…..
    Sorry for my poor english.

    • Check the file that is involved. If it begins with <? try changing that to <?php and see what happens. Depending on the php settings on your system (in php.ini) the short form <? might not be allowed.

  6. Hey, thx for the Grate mod. I have a Problem When i visit my site With my Handy. With dolphin Browser i dont See the Button and With the Android Browser / Chrome works fine but When i Press the like Button the Post is very long. Sorry for my Bad english… Any idea?

    • Ouch… I don’t remember having that problem in my testing. I’ll try again if I get time, but it’s been a while since I looked at that code and I tend to forget things even a week ago :)

  7. thank you for sharing the mod,
    I follow the step to install the mod,
    everything is going fine,
    but just one thing,
    the like button didn’t appear,
    if I point the mouse at the place “like” button locate,
    it still showing the little tag said “like this post”
    and I click it also will count and show the number of “like”,
    just can’t see the button,
    I try both gif and png icon already,
    how can I fix it?

    • Sorry – I don’t know the answer but it sounds like you’re pretty close to getting it to work. Maybe something is cached wrong or not in the correct directory? Just guessing.

  8. hi buddy,

    One of the requests I got on my forum was having a like system for posts so I went looking around and stumbled upon your method. It seemed the best way because it didn’t rely on modifications too heavily and it just works and with minor tweaking I managed to implement it successfully on my website. Thank you!

    As far as I can tell, I’ve had not had the reported problem of having been unable to post after liking something, but I’ll report back otherwise if I do run into problems.

    The one improvement I’d like to see for this is the ability to unlike a post if it’s possible? It seems once it’s been recorded it stays that way, but it’s a minor inconvenience.

    Thank you again!

    Kurtis -

    • Hi Kurtis,

      Glad you got it working, hopefully without too much trouble. Sorry though, I did not think of adding an “unlike” option. I don’t think it would be very difficult, but it’s just not something I have time for right now.


  9. I’ve run into a couple of issues.
    The Like button doesn’t display but the link is in the place where the button should be.
    If I click on the invisible button I get the following error:

    General Error
    SQL ERROR [ postgres ]

    ERROR: syntax error at or near “set” LINE 1: insert into phpbb_likes set likes_key=’11_4_14′,likes_who=’ … ^ []


    insert into phpbb_likes set likes_key=’11_4_14′,likes_who=’ Dave’,likes_count=’1′


    FILE: (not given by php)
    LINE: (not given by php)
    CALL: msg_handler()

    FILE: [ROOT]/includes/db/dbal.php
    LINE: 757
    CALL: trigger_error()

    FILE: [ROOT]/includes/db/postgres.php
    LINE: 211
    CALL: dbal->sql_error()

    FILE: [ROOT]/like.php
    LINE: 42
    CALL: dbal_postgres->sql_query()

    The only differences in my setup are that I’m using PostgreSQL and style proSpecial.
    Any ideas?


  10. Hi Dave,

    The ERROR: message seems a bit cut off in your note, so I’ll assume the SQL is like the next part of your note which says:

    insert into phpbb_likes set likes_key=’11_4_14′,likes_who=’ Dave’,likes_count=’1′

    That sure looks correct to me. So you might want to check if the problem is something simple like phpbb_likes not defined, or the fields not defined (such as typo in the creation of the database table). I use phpmyadmin, which I assume can also work with PostgreSQL for things like that. With phpmyadmin I would send the SQL above to the database processor and see what happens. So you might try that if you can, in order to isolate the SQL error and try to see what’s wrong.


    • Thanks, I don’t have phpmyadmin and I don’t really have time to set it up. So I’ll have to find a way round that.
      I’ve double checked that the table in SQL is the exact same name as in the PHP. When I run “insert into phpbb_likes set likes_key=’11_4_14′,likes_who=’ Dave’,likes_count=’1′” as a query in postgreSQL’s supplied management tool I get the same error:

      ERROR: syntax error at or near “set”
      LINE 1: insert into phpbb_likes set likes_key=’11_4_14′,likes_who=’D…

      ********** Error **********

      ERROR: syntax error at or near “set”
      SQL state: 42601
      Character: 25

      It’s a shame the error keeps getting truncated but it appears that postgreSQL doesn’t like the word “set” in the query. Either that or like you said, something isn’t defined properly. I copied and pasted everything from your example, just changing a couple of bits to correct paths etc for my environment. The main PHP is all the same though. So if you defined everything in your example it should be defined for me too.

      • Hmm… I just had a thought. Years ago I always coded MYSQL inserts like this:

        insert into table_name(field1,field2) values(data1,data2)

        … but later I found out I can use the same “set var=data” format on an insert as I do for an update. Since that’s one less thing to remember I started using that “set” method on insert all the time. I’m wondering if that’s an ability MYSQL has that postgreSQL doesn’t. If so, you might try changing that failing insert statement to:

        $likes_sql = “insert into phpbb_likes (likes_key,likes_who,likes_count) values(‘$likes_key’,'$likes_who’,'$likes_count’)”;

        Just guessing based on the error message,

        • One other thing – sounds like postgreSQL has a command line utility, as mysql has. In mysql I can do this:

          use bbsystem;
          show columns in phpbb_likes;

          | Field | Type | Null | Key | Default | Extra |
          | likes_key | varchar(100) | NO | PRI | | |
          | likes_count | int(11) | YES | | NULL | |
          | likes_who | varchar(255) | YES | | NULL | |

          And that should be a way to show that the database table is setup correctly. Of course you’ll probably have different a database and table name prefix than my test system.


  11. Thanks. I’ve just found the same thing after looking up the syntax for insert.
    I re-wrote the query to “insert into phpbb_likes (likes_key, likes_who, likes_count) values (’11_4_14′, ‘Dave’, ’1′)” and it ran perfectly and my like count has changed to 1 in phpBB. So I’ll re-write the queries in the PHP file and see if I can get it working. It’ll be good practice. This is my first time working with SQL queries.

    I’m confident we’ve resolved that issue, now I just need to figure out why the like button image isn’t displaying.

  12. I’ve now got the icon image working. I changed the line in colours.css to this:

    .like-icon, .like-icon a { background-image: url(“{T_THEME_PATH}/images/icon_post_like.gif”); }

    And then moved the gif to that folder. For some reason something must not have liked accessing the gif in the folder you suggested, even though I could access it in the browser directly. So I don’t understand why it wasn’t working.

    I’ve also updated like.php with the corrected SQL query syntax and it seems to be working so far, so hopefully I got it correct.

    Here’s how my like.php file looks now:


    // Initial var setup
    $forum_id = request_var(‘f’, 0);
    $topic_id = request_var(‘t’, 0);
    $post_id = request_var(‘p’, 0);

    $likes_user = $user->data['username'];

    $likes_key = $forum_id.’_’.$topic_id.’_’.$post_id;
    $likes_sql = “select * from phpbb_likes where likes_key=’$likes_key’”;
    $likes_result = $db->sql_query($likes_sql);
    $likes_row = $db->sql_fetchrow($likes_result);
    $likes_who = $likes_row['likes_who'];
    $likes_count = $likes_row['likes_count'];

    $split = explode(‘ ‘,$likes_who);

    if (!(array_search($likes_user,$split) !== FALSE))
    $likes_who .= “$likes_user”;
    if ($likes_count)
    $likes_sql = “update phpbb_likes (likes_who, likes_count) values (‘$likes_who’, ‘$likes_count’) where likes_key=’$likes_key’ limit 1″;
    $likes_result = $db->sql_query($likes_sql);
    $likes_count = 1;
    $likes_sql = “insert into phpbb_likes (likes_key, likes_who, likes_count) values (‘$likes_key’, ‘$likes_who’, ‘$likes_count’)”;
    $likes_result = $db->sql_query($likes_sql);

    $likes_back = str_replace(‘~’,'&’,$_GET['back']);
    header(“Location: viewtopic.php?$likes_back”);

    Hopefully that will display properly.
    Does the syntax look right to you now?


  13. If it works, it looks good to me :) As for the image, I’ll take a guess that might be a directory or file ownership issue. I probably issued a chown or chmod somewhere along the way and forgot about it.

  14. Upon further testing today I found an issue with my modified update query. I checked the syntax for update and found that your version was actually pretty much correct but the “limit 1″ at the end wasn’t needed and caused an error. I think limit is for select statements.

    So I ended up with this update query:

    $likes_sql = “update phpbb_likes set likes_who = ‘$likes_who’, likes_count = ‘$likes_count’ where likes_key = ‘$likes_key’”;

    That’s working for me so far. Thanks for your help!

  15. Hey!
    Works like a charm!
    How can I add Likes counter to every user?
    Iv’e tried to write SQL query that find the user by the “likes_key” value, then calculate how many like the user have in total and echo it in his profile, but it wont work well..
    Any one have idea?

    • Hi Rami, glad it worked for you.
      Just an initial guess, maybe you could code something like this:
      $sql = “select count() from phpbb_likes where likes_who like ‘% $user %’”;

      But that would mean each userid in the likes_who field would need to be surrounded by spaces – so you would need to change the code to add a space at the end of the field, I think. Probably better would be to add a counter field to the userid record, and bump up that count each time a like is recorded. Then you don’t have to read through the whole database hunting for the likes_who or likes_key fields.

      • Thank you for your answer!
        To know who is the user that other users gave him like I used:
        $user=SELECT poster_id FROM `phpbb_posts` WHERE post_id like $post_id
        SELECT username FROM `phpbb_users` where user_id like $user

        I want to add new column to each user in “phpbb_users” calld “user_likes” then when a user prss the Like button it would +1 the value in “user_likes”.
        Then all I need to do is to select the the value of “user_likes” to each user.

        How can I do this? do I need to add this in like.php?

  16. Hi Tom,

    I just stumbled across this while searching for a “Like Post” button option for phpBB. I’m currently running version 3.0.12. Will your mod work with this version? Are there any currently known conflicts? Thanks!

  17. Hi Andy, thanks for taking a look. But… I can’t tell you if the mod will work for 3.0.12 or not. I would say give it a try if you can’t find anything else, but of course keep a copy of your original source for a backout. If you do try the changes, please let me know how it goes. Tom

    • I have installed the mod on 3.0.12 and it appears to be working as intended. I do not see any errors or issues with it.

      I do have a question though. Is it possible to show the like count for logged out guest users too? I think I’d want the like button hidden to guests, but having the like count show would be nice. Any thoughts on that?

      Thanks, seems to work like a charm!

  18. Hi Andy, sounds good so far! When I setup the Like button for myself, I had phpBB set so no Guest access was allowed. As a test, I changed all forums to read-only for Guest, and sure enough – the Like button doesn’t show up. This isn’t anything I did on purpose or even considered, it just happened that way. I’ll bet the system is using different html templates for the different modes (update vs. read-only). If so, I need to find the read-only html and make some updates to that as needed. I will look, but I can’t promise anything. Tom.

  19. Hi this is the one that i have been looking for :) amazing work!.
    I completed the installation and ever things seem to be working fine except the like button isn’t display. I know the button is there because when i hover my mouse around the area, “Like this post” text pop up beside the “report this post and quote”. I can even like the post and show “1 like” but the button isn’t display there.

    I have tried many different codes, tweaking here and there but cannot seem to figure it out.
    I am using a style call we_clearblue and i have uploaded the icon to the correct file directory.

    There are some of the different line that i have tried but does’t work.
    .like-icon, .like-icon a { background-image: url(“{IMG_ICON_POST_LIKE_SRC}”) }
    .like-icon, .like-icon a { background-image: url(“{T_THEME_PATH}/images/icon_post_like.gif”); }
    .like-icon, .like-icon a { background-image: url(“/bb/styles/we_clearblue/imageset/en/icon_post_like.gif”); }
    .like-icon, .like-icon a { background-image: url(“{T_THEME_PATH}/images/icon_post_like.gif”); }

    I hope u can help me figure it out.

    Thanks alot

  20. Hi vapual,

    I’m not sure what could be wrong. I’ll guess the code just isn’t matching the location of the gif image file, or maybe the image file is not readable (chown permission bits) by apache. Maybe one way to figure this out would be to find the code for the Edit button (which should be nearby the code for the Like button) and see why the Edit button works and the Like button doesn’t. The old A/B test where one thing works and one thing doesn’t is sometimes a good way to solve problems. For example, change the Like graphic code to look exactly like the Edit button, and then you should see two edit buttons (of course the one on the left will be the Like function). Then perhaps put the Like gif in the same disk location as the Edit gif, and alter the code slightly to use the new Like gif.


  21. Hi this is the quote and edit line

    .quote-icon, .quote-icon a { background-image: url(“{IMG_ICON_POST_QUOTE_SRC}”); }
    .edit-icon, .edit-icon a { background-image: url(“{IMG_ICON_POST_EDIT_SRC}”); }

    so i change my line to
    .like-icon, .like-icon a { background-image: url(“{IMG_ICON_POST_LIKE_SRC}”) }

    but still it won’t show. How may i fix this?

  22. Hey Tom,

    Installed and working on 3.011 just fine with the exception that when a user likes a post it refreshes to the top of the page instead of the post they were actually liking. Any ideas where this may be looping? Thanks!

    • I think you might be able to change the 4th from the last line in likes.php to this:

      $likes_back = str_replace(‘~’,'&’,$_GET['back']).”#p$post_id”;

      And that should cause the browser to scroll down to the anchor point of the post. Not sure, but this might cause other problems. Please give it a try and let me know how it goes when you have time.

        • Sounds good! Let me know if you see any unwanted side-effects. A better way of doing this might be to use javascript to update the Like text locally on the screen when the button is pushed, without refreshing the entire screen. I don’t know how to do that so I’m stuck using the simpler methods.

          • Hi Tom! This mod works amazing and my users love it!
            Except for the issue of the page refreshing to the top.
            I did the change above but receive this error when clicking the like button.

            Parse error: syntax error, unexpected ‘~’ in /home/vsdealsi/public_html/like.php on line 46

  23. Hi Tom! This is exactly what I need-and my users are demanding.
    My problem is I just don’t understand how to create the mysql table in phpmyadmin.
    Can you help? Thank you!

    • Hi keyleyr, I think it should be pretty simple. On my system I just click my database name to the left so the program knows what database I’m dealing with. Then I click the SQL tab and a window appears where you can copy/paste in the SQL to create the table, and push the Go button to make it happen. If you are not that familiar with phpmysql you might want to create some test databases and tables and work with it a bit. It’s a great program and I sure wouldn’t want to be without it. However, there is a line-mode interface too – the mysql command in Linux (if that is what you are running). I’ve used that too, but I’d much rather use phpmyadmin.

  24. Hey!

    I did everything step by step, but the button doesnt appear and even if I hover over the area where the button is supposed to be nothing shows up.
    I’m using oxygen theme (subsilver2).

    • Hi Jimi,

      Sorry, I don’t know what to tell you other than to look at some of the other comments from folks that had similar issues. I just don’t know enough about how phpBB finds graphics. Maybe try changing the permission bits of the graphic file, or perhaps move it other directories and hope for the best.


  25. Dude! Thank you for posting this! The instructions were very easy to follow and I now have a working like button on my forum! Nice!

  26. … ok. so you guys just demonstrated HOW WAY TOO COMPLICATED PHPBB is.

    absolutely catastrophic.

    i guess people are better off and faster writing their own software instead of MWOPC (MESSING WITH OTHER PEOPLE’S CODE)

    • Well, “you guys” is just poor Tom, but that’s ok :) But I’ve been there too, having to make modifications to systems that are so complex and undocumented that you keep saying to yourself it would be far easier to just rewrite the whole thing. Well, in almost all cases you would be wrong. So many times I’ve seen that course taken (including by me), and so many times I’ve seen failures – or at best the resulting program is no better than what came before. In other words, it’s easy to say “I could do all this better myself”, but it’s not that easy to actually go out and do.

  27. Thank You Tom,
    Your mod is wonderful and it works good. But I have a question for this. What can ı work this mod with ajax? Because I dont want to refresh page. Is it possible?

    • I’m sure it’s possible. I probably used spaces between user names in the likes_who field because of a couple of reasons (but I can’t remember completely). 1) A field with spaces displayed in HTML will wrap around at those spaces nicely. 2) My user names had no spaces in them.

      If you just want to display the names with commas between them instead of a space, I’m thinking you can just replace the spaces with commas before setting up the field for display. For example, around this existing code:

      if ($likes_count == 1) $likes_text = “<a href=’#’ title=’$likes_who’ rel=”nofollow”>1 Like“;
      if ($likes_count > 1) $likes_text = “<a href=’#’ title=’$likes_who’ rel=”nofollow”>$likes_count Likes“;

      You might add this line up front:

      $likes_who = str_replace(‘ ‘,’,',$likes_who);

      That tells php to replace any space with a comma. And since in my case, user names had no spaces within them, I think that would work.

  28. i am not able to see any changes in forum page, i am doing all the steps apart from backing up the data files…still not able to see the like button

    • Whenever I make changes and nothing appears to happen, I start adding “echo” statements to show various text so I can hopefully find out what’s going on. You might give that a try. Or as a last resort, change some phpBB text or logic and make sure that temp change goes into effect, that way you know you are editing the proper file and that you have caching turned off (see above).

    • Thanks – I can do some php programming, but not much javascript. I think it would take some local javascript to update the Like and also update the database without a page reload, but that’s beyond my current capabilities. I never thought about notification, I guess I figured a person who wants to see how many Likes they get would just go look.

      But what about the previous post here? My mod is so old it has to have been replaced with something standard by now.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>