IMPORTANT

FM Design is in read-only mode, please click here for more information.

Latest topics
» Forumactif Edge - Releases
by Ange Tuteur Tue 09 Oct 2018, 11:34

» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28

» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15

» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11

» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24

» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58

» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50

» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22

» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12

» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10

» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51

» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11

» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19

» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34

» Numbering of messages in the topic
by SLGray Mon 04 Dec 2017, 22:40

Recent Tutorials
Top posting users this month

Who is online?
In total there are 3 users online :: 0 Registered, 0 Hidden and 3 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 2 of 3 Previous  1, 2, 3  Next

View previous topic View next topic Go down

avatar
Ange Tuteur
Administrator
Gender : Male
Age : 23
Posts : 4736
Points : 10027
Reputation : 2369
Location : Macungie, PA
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
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

--------

Ange Tuteur
Tips and TricksContact Me


avatar
Theshaka

Gender : Male
Age : 24
Posts : 31
Points : 1695
Reputation : 0
Language : Polish,English,French
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
View user profile http://seiya.forumotion.com/

PostTheshaka on Wed 01 Apr 2015, 11:14

I have problem:
Like
8 People like this post.

But don't show names:
Ch@lo Valdez, Rhino.Freak, Grow, Niko!, AlexisMcDevin, Ikerepc, smejker
avatar
Ange Tuteur
Administrator
Gender : Male
Age : 23
Posts : 4736
Points : 10027
Reputation : 2369
Location : Macungie, PA
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Wed 01 Apr 2015, 11:45

Is it a post that has been liked before the installation of this script ?

--------

Ange Tuteur
Tips and TricksContact Me

avatar
Theshaka

Gender : Male
Age : 24
Posts : 31
Points : 1695
Reputation : 0
Language : Polish,English,French
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
View user profile http://seiya.forumotion.com/

PostTheshaka on Wed 01 Apr 2015, 11:47

I try like new post now and it saying loading... for few sec but don't show names.
avatar
Ange Tuteur
Administrator
Gender : Male
Age : 23
Posts : 4736
Points : 10027
Reputation : 2369
Location : Macungie, PA
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Wed 01 Apr 2015, 11:49


--------

Ange Tuteur
Tips and TricksContact Me

avatar
Theshaka

Gender : Male
Age : 24
Posts : 31
Points : 1695
Reputation : 0
Language : Polish,English,French
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
View user profile http://seiya.forumotion.com/

PostTheshaka on Wed 01 Apr 2015, 11:57

Done but still loading... for few sec and not show names who like, and here i am using same pid as in the Shoutbox?
avatar
Ange Tuteur
Administrator
Gender : Male
Age : 23
Posts : 4736
Points : 10027
Reputation : 2369
Location : Macungie, PA
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Thu 02 Apr 2015, 14:42

You should make a new reply to the database topic with the correct database table as the message content. E.G. :
Code:
[table class="database_table" id="fa_likes"][tr][td]Post ID[/td][td]Users[/td][/tr][/table]

If you're using the same post it's going to cause problems.

--------

Ange Tuteur
Tips and TricksContact Me

avatar
Theshaka

Gender : Male
Age : 24
Posts : 31
Points : 1695
Reputation : 0
Language : Polish,English,French
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
View user profile http://seiya.forumotion.com/

PostTheshaka on Thu 02 Apr 2015, 16:17

@Ange Tuteur wrote:You should make a new reply to the database topic with the correct database table as the message content. E.G. :
Code:
[table class="database_table" id="fa_likes"][tr][td]Post ID[/td][td]Users[/td][/tr][/table]

If you're using the same post it's going to cause problems.

i have x3 of this now Confused
avatar
Ange Tuteur
Administrator
Gender : Male
Age : 23
Posts : 4736
Points : 10027
Reputation : 2369
Location : Macungie, PA
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Thu 02 Apr 2015, 16:22

You only need one for each table, so delete the extra tables of this.

--------

Ange Tuteur
Tips and TricksContact Me

avatar
Theshaka

Gender : Male
Age : 24
Posts : 31
Points : 1695
Reputation : 0
Language : Polish,English,French
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
View user profile http://seiya.forumotion.com/

PostTheshaka on Fri 03 Apr 2015, 09:56

ok i deleted 2 and i have 2, but it still not showing names
avatar
Ange Tuteur
Administrator
Gender : Male
Age : 23
Posts : 4736
Points : 10027
Reputation : 2369
Location : Macungie, PA
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Sat 04 Apr 2015, 17:14

Click the edit button on your likes table and replace the contents with this :
Code:
[table class="database_table" id="fa_likes"][tr][td]Post ID[/td][td]Users[/td][/tr][/table]

That looks like chatbox message data from your screen shot. Make sure the PID for the script is the same as your likes table, and that the reputation system is enabled. Furthermore a group for members is needed for them to modify the table.

--------

Ange Tuteur
Tips and TricksContact Me

avatar
Theshaka

Gender : Male
Age : 24
Posts : 31
Points : 1695
Reputation : 0
Language : Polish,English,French
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
View user profile http://seiya.forumotion.com/

PostTheshaka on Fri 10 Apr 2015, 08:21

meh not work Confused
avatar
Michael_vx

Gender : Male
Age : 26
Posts : 302
Points : 2133
Reputation : 76
Language : Arabic
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
View user profile http://miccsoft.net https://www.facebook.com/Michaelvx2008

PostMichael_vx on Fri 10 Apr 2015, 12:32

hi again
is this project ready for other versions like phpbb2 ?
avatar
Miltonius
New Member
Gender : Unspecified
Posts : 2
Points : 1344
Reputation : 1
Language : English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
View user profile

PostMiltonius on Mon 13 Apr 2015, 09:30

hello there , any chance to make this system for punbb?
avatar
Michael_vx

Gender : Male
Age : 26
Posts : 302
Points : 2133
Reputation : 76
Language : Arabic
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
View user profile http://miccsoft.net https://www.facebook.com/Michaelvx2008

PostMichael_vx on Mon 13 Apr 2015, 17:21

i think our legendary coder is busy these days
we need to wait i guess
take your time boss
avatar
Ange Tuteur
Administrator
Gender : Male
Age : 23
Posts : 4736
Points : 10027
Reputation : 2369
Location : Macungie, PA
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Mon 13 Apr 2015, 22:44

@Miltonius wrote:hello there , any chance to make this system for punbb?
The script above is only for phpbb3. Unfortunately I've not rewrote the script for all versions, yet.

--------

Ange Tuteur
Tips and TricksContact Me

avatar
Michael_vx

Gender : Male
Age : 26
Posts : 302
Points : 2133
Reputation : 76
Language : Arabic
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
View user profile http://miccsoft.net https://www.facebook.com/Michaelvx2008

PostMichael_vx on Tue 14 Apr 2015, 04:07

okay ill wait
i hope it been soon Smile
thanks again our legendary coder
avatar
Theshaka

Gender : Male
Age : 24
Posts : 31
Points : 1695
Reputation : 0
Language : Polish,English,French
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
View user profile http://seiya.forumotion.com/

PostTheshaka on Sun 03 May 2015, 13:25

Yo it almost work almost because it show only me - my name when i like posts, for other users it not work
avatar
Theshaka

Gender : Male
Age : 24
Posts : 31
Points : 1695
Reputation : 0
Language : Polish,English,French
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
View user profile http://seiya.forumotion.com/

PostTheshaka on Mon 01 Jun 2015, 15:10

@Theshaka wrote:Yo it almost work almost because it show only me - my name when i like posts, for other users it not work
up up?
avatar
brandon_g

Gender : Unspecified
Age : 21
Posts : 458
Points : 2114
Reputation : 67
Location : USA
Language : English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : phpBB2
View user profile http://broadcastingduo.forumotion.com

Postbrandon_g on Mon 01 Jun 2015, 16:29

What problem precisely do your users have with it?
avatar
celestial spirit
New Member
Gender : Unspecified
Posts : 8
Points : 1309
Reputation : 2
Language : english
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
View user profile

Postcelestial spirit on Mon 01 Jun 2015, 21:15

don't ask me what i did wrong but for some reason members that aren't me can't use the like button so i did something to make it admins only but they can still see the button
avatar
brandon_g

Gender : Unspecified
Age : 21
Posts : 458
Points : 2114
Reputation : 67
Location : USA
Language : English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : phpBB2
View user profile http://broadcastingduo.forumotion.com

Postbrandon_g on Tue 02 Jun 2015, 10:53

Are they trying to like someone else's posts or their own? Because if it is their own, they will not be able to. This is supposed happen.

If this is not the case, may you please include the following info in your post:
->The current code for your like system
->A screenshot of what the members' having trouble are seeing

this way we can better assist you.

-Brandon
avatar
celestial spirit
New Member
Gender : Unspecified
Posts : 8
Points : 1309
Reputation : 2
Language : english
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
View user profile

Postcelestial spirit on Wed 03 Jun 2015, 16:14

the code for the like button is the exact same as here except with my info i know i did the database right because the shoutbox and views work perfectly but for some reason only admins on my forum can use the like button but everyone can see it
avatar
brandon_g

Gender : Unspecified
Age : 21
Posts : 458
Points : 2114
Reputation : 67
Location : USA
Language : English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : phpBB2
View user profile http://broadcastingduo.forumotion.com

Postbrandon_g on Fri 05 Jun 2015, 08:58

Are you sure only admins can use it? I am not sure if that is even possible. It might be, would have to wait for @Ange Tuteur to reply though.

Meanwhile, may you ask your users for a screenshot of what they see?
avatar
qmars(pkq)
New Member
Gender : Unspecified
Posts : 1
Points : 1271
Reputation : 0
Language : peresian
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
View user profile

Postqmars(pkq) on Sun 21 Jun 2015, 05:09

hi Ange Tuteur!
if u remmember i needed this system alot!
now i cant use it Sad
it dont write name of who like it just write 1 person like it
avatar
brandon_g

Gender : Unspecified
Age : 21
Posts : 458
Points : 2114
Reputation : 67
Location : USA
Language : English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : phpBB2
View user profile http://broadcastingduo.forumotion.com

Postbrandon_g on Tue 23 Jun 2015, 09:19

Hello @qmars(pkq) ,

What is exactly is your problem? Have you installed the database topic? That is needed for this to work.

-Brandon
Sponsored content

PostSponsored content

Page 2 of 3 Previous  1, 2, 3  Next

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