Latest topics
» IconSkouliki Graphics
by skouliki Fri 20 Oct 2017, 05:08

» "Edit this page" feature
by skouliki Fri 20 Oct 2017, 01:37

» Dark Mode + Another Question
by Haggis Thu 19 Oct 2017, 10:36

» [GAME] Count to 1000 using even numbers Van-Helsing Edition
by Van-Helsing Tue 17 Oct 2017, 15:07

» [GAME] What are you thinking right now?
by Ace 1 Tue 17 Oct 2017, 08:09

» [GAME] Count to One Million!
by Ace 1 Tue 17 Oct 2017, 08:07

» [GAME] Last Letter Game
by Ace 1 Tue 17 Oct 2017, 08:06

» [GAME] World Snake
by Ace 1 Tue 17 Oct 2017, 08:06

» [GAME] Never have I ever..
by Ace 1 Tue 17 Oct 2017, 08:06

» [GAME] Animal Game
by universecat Mon 16 Oct 2017, 21:43

» [GAME] Post a random picture
by SLGray Mon 16 Oct 2017, 16:28

» Hi everyone!
by skouliki Mon 16 Oct 2017, 02:01

» Hai Guys~
by skouliki Mon 16 Oct 2017, 01:59

» Add a login popup for the toolbar
by Ape Sun 15 Oct 2017, 13:51

» Mobile Usability Test
by Ange Tuteur Sat 14 Oct 2017, 11:20

Recent Tutorials
Who is online?
In total there are 7 users online :: 0 Registered, 0 Hidden and 7 Guests :: 1 Bot

None

[ View the whole list ]


Most users ever online was 172 on Fri 19 Feb 2016, 05:17

[phpbb3] Like system that shows who liked a post

Page 3 of 3 Previous  1, 2, 3

View previous topic View next topic Go down

avatar
Ange Tuteur
Administrator
Title :
Coffee Addict
Gender : Male
Age : 21
Posts : 4698
Points : 9540
Reputation : 2337
Location : Macungie, PA
Language : EN10, FR5
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Tue 20 Jan 2015, 02:07

First topic message reminder :

The content in this test is experimental, and all instructions SHOULD be READ and FOLLOWED. Failure to do so may cause unwanted side effects. USE WITH CAUTION !!

As many people want a like system to show who liked posts, I'll give you the chance to test it. You should know already that our forums do not have databases which we can interact with and the majority have no idea how to use a database. This plugin will make use of a topic as a database to store like information. This will require a group with moderation privileges. Before you continue, please take note of the following.

  • This was developed for phpbb3 and is not guaranteed to work on other versions
  • The method to store data is not secure, and can be overwritten or deleted ( it's recommended to keep backups of DBs )

This test should help you achieve the following, if done correctly.



Creating a new table

To create a new table in your database, you first need to follow the installation process here : http://fmdesign.forumotion.com/t281-fa_db-database-installation

If you followed the tutorial above, paste the code below as the topic contents. Otherwise if you've already set your database up, click "edit database" and scroll down to the quick reply to add a new table.
Code:
[table class="database_table" id="fa_likes"][tr][td]Post ID[/td][td]Users[/td][/tr][/table]


Installation

So our like button has a style go to Administration Panel > Display > Colors > CSS stylesheet, and paste the following codes.
Code:
/* START fa_like */
.fa_like_row { margin-top:6px }
.fa_like_list { font-style:italic; min-height:25px; }
a.fa_like_button, .fa_like_button, .fa_liked { color:#FFF; font-size:10px; background:#6A6; border:1px solid #686; border-radius:3px; display:inline-block; padding:3px 6px; cursor:default; }
.fa_liked { cursor:default; opacity:0.3; }
a.fa_like_button:hover { background:#3A3; border:1px solid #383; cursor:pointer; }
/* END fa_like */


Finally the last part you've been waiting for, the like system. Create another script :

Title : fa_likes
Placement : In the topics
Code:
$(function(){
  var pid = 270,
  i = 0,
  lang = {
    like : 'Like',
    loading : 'Loading...',
    people : 'People like this post.',
    person : 'Person likes this post.'
  };
 
  $('.post').each(function() {
    var plus = $(this).find('.vote-button:first a'), id = $(this).attr('id').slice(1), clear = $(this).find('.clear'), votes = 0, text = lang.people;
 
    if (plus.length) clear.after('<div class="fa_like_row"><a class="fa_like_button" href="'+plus.attr('href')+'">'+lang.like+'</a></div>');
    else clear.after('<div class="fa_like_row"><span class="fa_liked">'+lang.like+'</span></div>');
 
    if ($(this).find('.vote-bar').length) {
      votes = Number($(this).find('.vote-bar').attr('title').replace(/.*?\((\d+)\s.*/,'$1'));
      if (votes == 1) text = lang.person;
    }
 
    $(this).find('.fa_like_row').append('<div class="fa_like_text">'+votes+' '+text+'</div><div class="fa_like_list" id="fa_like_list'+id+'">Loading...</div>');
    $(this).find('.vote').remove();
 
  i++;
  if (i==$('.post').length) {
      $.get(_database.tid, function(data) {
      $('.post').each(function() {
        var id = $(this).attr('id').slice(1), dblikes;
          $('#fa_like_list'+id).html('');
          if ($('#fa_likes #likes'+id,data).length) {
            dblikes = $('#fa_likes #likes'+id,data).text().replace(/likes=\{(.*?)\}/,'$1').split(',');
            for (var i=0; i<dblikes.length; i++) {
              var comma = ', ';
              if (i==dblikes.length-1) comma = '';
              $('#fa_like_list'+id).append(dblikes[i].replace(/^(.*?):(.*?)$/,'<a href="/u$1">$2</a>'+comma))
            }
          }
      });
    });
  }
  });
 
  $('.fa_like_button').on('click', function() {
    var id = $(this).attr('href').replace(/^.*?p\_vote=(\d+)$/,'$1');
    $(this).after('<span class="fa_like_button">'+lang.loading+'</span>').hide();
    $.get($(this).attr('href'), function() {
    _database.post({
        pid : pid,
        tableid : 'likes'+id,
        update : ['\\[td id="likes'+id+'"\\]likes=\\{(.*?)\\}\\[/td\\]','[td id="likes'+id+'"]likes={$1,'+_userdata.user_id+':'+_userdata.username+'}[/td]'],
        newRow : '[tr][td]t'+window.location.pathname.replace(/\/t(\d+).*/,'$1')+'p'+id+'[/td][td id="likes'+id+'"]likes={'+_userdata.user_id+':'+_userdata.username+'}[/td][/tr]',
        reload : true
      });
    });
    return false;
  });
});

You must make sure to change the pid to your database table ID. To do that, edit the post which contains your like table, and copy / paste the following portion of the URL as the PID value.


When finished, it should look like the following, except a different ID.
Code:
pid = 270,

Save the script, and it should now be setup if you followed all steps correctly !! Go like some posts and the database should then update with a new table row for posts that haven't been liked. When you visit posts, they should display who liked them if it's logged within the database.


If you have any questions or comments you may leave them below. Have fun with this experimental system ! Monster


Last edited by Ange Tuteur on Mon 16 Feb 2015, 00:45; edited 1 time in total

avatar
chandoi
New Member
Title :
Gender : Unspecified
Posts : 1
Points : 853
Reputation : 0
Language : English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
Awards :
View all awards
View user profile

Postchandoi on Wed 24 Jun 2015, 11:37

I like this plug-in a lot! Just wondering if we can move the "like" button to the right? There might be some adjustment from css stylesheet, but I could not find it, can anyone help please?
Thanks in advance.
avatar
Van-Helsing

Title :
Coding Expert.
I.T Manager.
Web Developer.
Gender : Male
Age : 43
Posts : 844
Points : 2440
Reputation : 78
Location : Somewhere out there!
Language : English, Greek
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : punBB
Awards :
View all awards
View user profile http://itexperts.forumgreek.com/

PostVan-Helsing on Tue 14 Jul 2015, 12:49

Hello,
Is it possible to adapt it for punbb version?

--------

avatar
STBW

Title :
Gender : Unspecified
Posts : 33
Points : 1001
Reputation : 2
Language : Spanish
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile

PostSTBW on Wed 15 Jul 2015, 02:58

Is possible to add the dislike button as well? Thanks!
avatar
STBW

Title :
Gender : Unspecified
Posts : 33
Points : 1001
Reputation : 2
Language : Spanish
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile

PostSTBW on Mon 27 Jul 2015, 02:15

bump? Razz
avatar
STBW

Title :
Gender : Unspecified
Posts : 33
Points : 1001
Reputation : 2
Language : Spanish
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile

PostSTBW on Tue 18 Aug 2015, 08:16

bump!
avatar
Van-Helsing

Title :
Coding Expert.
I.T Manager.
Web Developer.
Gender : Male
Age : 43
Posts : 844
Points : 2440
Reputation : 78
Location : Somewhere out there!
Language : English, Greek
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : punBB
Awards :
View all awards
View user profile http://itexperts.forumgreek.com/

PostVan-Helsing on Wed 21 Oct 2015, 17:44

Hello dear all,
I tried to install it on a greek forum(PHPBB3) but it is not working and the pseudo-database is not updating after pressing "Like" button

it displays


the topic links format is /t000-topic

where 000 is the topic number. Are the codes needs any kind of modification?
avatar
Ange Tuteur
Administrator
Title :
Coffee Addict
Gender : Male
Age : 21
Posts : 4698
Points : 9540
Reputation : 2337
Location : Macungie, PA
Language : EN10, FR5
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Thu 22 Oct 2015, 19:06

I'm assuming it's related to the forum language. Does it do the same in English ?
avatar
Van-Helsing

Title :
Coding Expert.
I.T Manager.
Web Developer.
Gender : Male
Age : 43
Posts : 844
Points : 2440
Reputation : 78
Location : Somewhere out there!
Language : English, Greek
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : punBB
Awards :
View all awards
View user profile http://itexperts.forumgreek.com/

PostVan-Helsing on Fri 23 Oct 2015, 05:43

Hello @Ange Tuteur,
I didn't test it in a forum with English language. Is there a way to fix this problem?

--------

avatar
Ange Tuteur
Administrator
Title :
Coffee Addict
Gender : Male
Age : 21
Posts : 4698
Points : 9540
Reputation : 2337
Location : Macungie, PA
Language : EN10, FR5
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Sat 24 Oct 2015, 11:17

@Dark-Avenger not at the moment. I've discontinued work on the database project awhile ago since it's inefficient, complicated to setup, and has a hoard of problems.

Personally, I'd recommend not installing this due to the facts mentioned above. This, and I'll shortly be moving the database project content into isolation. Don't worry, it'll still be visible, but there will be little to no support as I plan on moving on to other projects. I first need to start with cleaning up this forum, though. bounce

Page 3 of 3 Previous  1, 2, 3

View previous topic View next topic Back to top

Create an account or log in to leave a reply

You need to be a member in order to leave a reply.

Create an account

Join our community by creating a new account. It's easy!


Create a new account

Log in

Already have an account? No problem, log in here.


Log in

 
Permissions in this forum:
You cannot reply to topics in this forum