News:

Welcome to the Unofficial Help Forum



Author Topic: SMF Likes Plus  (Read 113854 times)

Offline Illori

  • Administrator
  • *
  • Posts: 319
    • View Profile
SMF Likes Plus
« on: February 28, 2013, 09:33:41 PM »
We now have a Likes mod.





You can Like or Unlike each post but a post that you make.

If more then 5 people have liked a post it will not show the names to save space.

Be sure after the mod is installed to set the permissions for which groups can like the posts. If you want a board to not have likes you would need to create a Permissions Profile to deny/disallow the liking in that board.



This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
« Last Edit: April 18, 2013, 09:27:03 AM by Illori »

Offline Dzonny

  • Team Member
  • *
  • Posts: 3
    • View Profile
Re: SMF Likes Plus
« Reply #1 on: March 05, 2013, 12:36:25 PM »
Thanks  Illori, works great! :)


Offline Illori

  • Administrator
  • *
  • Posts: 319
    • View Profile
Re: SMF Likes Plus
« Reply #2 on: March 05, 2013, 01:41:42 PM »
great to hear.

Offline Sully

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: SMF Likes Plus
« Reply #3 on: March 14, 2013, 11:41:50 AM »
Is there a reason my post was deleted? First of all, I had a valid question - because I'm curious as to who writes the modifications for this team. Second of all, which is the more surprising and actually slightly concerning reason that my post was deleted, is because I said that there are valid issues with the way this modification loads its resources.

Somewhat astounding to me that you'd ignore someone helping and then remove their post so no one else see's the truth.

The efficiency with this modification isn't something to be ignored, it could cause some big problems on larger boards in regards to performance.

Offline Arantor

  • Team Member
  • *
  • Posts: 82
    • View Profile
Re: SMF Likes Plus
« Reply #4 on: March 15, 2013, 11:19:44 AM »
Not that it's any of your business who writes the modifications, but Illori did a lot of the ground work, and I helped out because I'm nice.

Quote
because I said that there are valid issues with the way this modification loads its resources.

There are valid issues, no disagreement, but they are actually the least worst alternative. I did exactly the same thing in Wedge for exactly the same reason, in fact.

It's really straightforward: if you do it any other way, you are pretty guaranteed to give some users a bad experience in some shape or form. Because caching isn't an answer here.

To explain: normally when you update something you generally want to play clearing the cache, especially if the user who has just done something wants to see that it has been done - in this case, liking a post, you *really really* want to show them that they've liked it.

Except you cannot flush the cache from the like call itself for the simple reason that you cannot guarantee what you will be flushing, unless you cache every like for the entire topic, because that's the only way you can do it.

If you cache by the list of messages, that's fine right up until users can view the page with different numbers of messages, since it's an option in their profile. So you will at some point be using stale data or being inconsistent with what you do show. At Facebook scale, inconsistent data is fine, but on a smaller scale, it's not acceptable.

If you cache by page number, you're going to have incomplete data depending on who happens to be rebuilding the cache, it may have more or less data than what other users need.

Quote
Somewhat astounding to me that you'd ignore someone helping and then remove their post so no one else see's the truth.

Just like removing bad reviews to your products, eh?

Quote
The efficiency with this modification isn't something to be ignored, it could cause some big problems on larger boards in regards to performance.

Oh yes, that's a valid point. And for those, a customised caching solution would be implemented. Folks with big boards will have invariably forced the posts per page, meaning it's possible to implement sane caching with this.

Oh, and actually, we have this running on wedge.org in a slightly modified form (since that's where I got the code from originally after I'd worked it all out and benchmarked it) and it's working just fine. I realise that 30k posts isn't a huge forum but it's actually large enough for testing - most people with 100k+ forums have enough going on that they don't really need to add this anyway.

Offline BGH

  • Jr. Member
  • *
  • Posts: 15
    • View Profile
Re: SMF Likes Plus
« Reply #5 on: March 19, 2013, 09:26:28 AM »
Works great Illori, thanks!

Is there a way to cut off the list of users who liked the post "the way Facebook does"? (example: "testuser1, testuser2, testuser 3 and 5 others like this", maybe adding a popup showing all people who likes).

I know it might not be the purpose of this mod, but could be a nice addition ;D.


 :-X My bad, sorry. Didn't read the first post where it states:

If more then 5 people have liked a post it will not show the names to save space.

Could it be posible to add a popup box showing all likes, though?

Thanks in advance!

Cheers!
« Last Edit: March 19, 2013, 11:59:48 AM by BGH »

Offline Illori

  • Administrator
  • *
  • Posts: 319
    • View Profile
Re: SMF Likes Plus
« Reply #6 on: March 20, 2013, 06:12:45 AM »
at this time to show the additional names in a popup is beyond my coding skills but i will see what can be done.

Offline BGH

  • Jr. Member
  • *
  • Posts: 15
    • View Profile
Re: SMF Likes Plus
« Reply #7 on: March 20, 2013, 01:29:01 PM »
Ok, thank you :D. I'm thinking that one posibilty could be to add all the names in a preview tooltip (don't know if that's the proper way to call it), so it shows the preview up when hovering the "like.png" image, for example. But I'm not sure if this is entirely posible, though.

Another thing: Would it be posible to add a profile link to the usernames those who liked? For example:

Quote
2 Likes BGH, testuser like this

Though, if I'm not mistaken, that'll make the query a bit heavier.

And thank you again for this mod, I made it to look similar to VB's likes system, so it's proven to be very customisable :D.

Best Regards.

Offline Arantor

  • Team Member
  • *
  • Posts: 82
    • View Profile
Re: SMF Likes Plus
« Reply #8 on: March 22, 2013, 11:51:53 AM »
Quote
Though, if I'm not mistaken, that'll make the query a bit heavier.

It makes precisely zero difference whether you're making a link out of it or not in terms of queries - you already have to query to fetch the name, and if you have a name, you can just fix up a link out of it.

There is an updated version in testing which includes that, a couple of other minor presentation things (namely '1 Likes' getting fixed) and just for fun there's also a popup. Presentation on that is not entirely the best but there's something of a limit to what can be done in SMF's help popup.

Offline Illori

  • Administrator
  • *
  • Posts: 319
    • View Profile
Re: SMF Likes Plus
« Reply #9 on: March 22, 2013, 12:22:31 PM »
new version attached to the first post. let me know if you run into any issues.

Offline BGH

  • Jr. Member
  • *
  • Posts: 15
    • View Profile
Re: SMF Likes Plus
« Reply #10 on: March 23, 2013, 06:09:34 AM »
Awesome, excellent work! I've been playing with it for a short time, and came to love it  ;D.

There is an updated version in testing which includes that, a couple of other minor presentation things (namely '1 Likes' getting fixed) and just for fun there's also a popup. Presentation on that is not entirely the best but there's something of a limit to what can be done in SMF's help popup.

I was more thinking on a DIV centered little box, but that does the job done too. Can you please point me out where I can edit the popup style if possible?

Thanks for all your dedication, people! :D

Offline Illori

  • Administrator
  • *
  • Posts: 319
    • View Profile
Re: SMF Likes Plus
« Reply #11 on: March 23, 2013, 06:13:43 AM »
styling the popup is a bit of an issue, doing it right would basically require a new template. currently it is reusing the help popup. i may look into doing this in the future but i am not sure it is going to happen.

Offline BGH

  • Jr. Member
  • *
  • Posts: 15
    • View Profile
Re: SMF Likes Plus
« Reply #12 on: March 23, 2013, 06:23:41 AM »
Ok, thank you, Illori, but as I said it just does the job done. :D

Will try to modify the table style, though.

Best regards.

Offline Illori

  • Administrator
  • *
  • Posts: 319
    • View Profile
Re: SMF Likes Plus
« Reply #13 on: March 23, 2013, 07:37:15 AM »
it may be useful to others if you could post your edits to the mod.

Offline BGH

  • Jr. Member
  • *
  • Posts: 15
    • View Profile
Re: SMF Likes Plus
« Reply #14 on: March 23, 2013, 09:30:24 AM »
Sure, this is what I did so far (though, it's a bit raw):

  • Centered 'The following liked this post:' text by including it within a div box
  • Centered the avatar cell
  • Added a cellspadding to the table, to make it look neater
  • Added a top and bottom border to the table
  • Added some padding and margin to both, to make it look neater
  • Added a link to the profile for the likers ;) with a target=_"blank" attribute, so it opens on another window when it's clicked.


In Likes.php:

Find:

Code: [Select]
global $context, $txt, $smcFunc, $memberContext, $modSettings;
Replace with:

Code: [Select]
global $context, $txt, $smcFunc, $memberContext, $modSettings, $scripturl;
Find:

Code: [Select]
$context['page_title'] = count($likers) == 1 ? $txt['likes_popup_1'] : sprintf($txt['likes_popup_n'], comma_format(count($likers)));
$context['help_text'] = $txt['likes_popup_liked'];

$context['help_text'] .= '<table style="width: 100%">';
foreach ($likers as $liker)
{
loadMemberContext($liker);
$context['help_text'] .= '<tr><td>' . $memberContext[$liker]['name'] . '</td><td class="ava">' . $memberContext[$liker]['avatar']['image'] . '</td></tr>';
}
$context['help_text'] .= '</table>';

Replace with:

Code: [Select]
$context['page_title'] = count($likers) == 1 ? $txt['likes_popup_1'] : sprintf($txt['likes_popup_n'], comma_format(count($likers)));
$context['help_text'] = '<div style="text-align:center;margin:10px 0">' . $txt['likes_popup_liked'] . '</div>';

$context['help_text'] .= '<table style="width:100%;border-top:1px solid #ccc;border-bottom:1px solid #ccc;padding:10px 0" cellpadding="7">';
foreach ($likers as $liker)
{
loadMemberContext($liker);
$context['help_text'] .= '<tr><td class="ava" style="text-align:center">' . $memberContext[$liker]['avatar']['image'] . '</td><td><a href="' . $scripturl . '?action=profile;u=' . $liker . '" target="_blank" title="' . $txt['profile_of'] . ' ' . $memberContext[$liker]['name'] . '">' . $memberContext[$liker]['name'] . '</a></td></tr>';
}
$context['help_text'] .= '</table>';

Result snippet:

« Last Edit: March 25, 2013, 04:55:26 PM by BGH »