Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles

Reply
 
Thread Tools
How to turn the "Post Thank You" hack into a "Likes" system similar to vBulletin.org
BirdOPrey5's Avatar
BirdOPrey5
Join Date: Jun 2008
Posts: 10,610

The details of my life are quite inconsequential.

New York
Show Printable Version Email this Page Subscription
BirdOPrey5 BirdOPrey5 is offline 07-05-2011, 10:00 PM

Note: These instructions are for VB 3.8. See post #35 by michal72 for a VB4 adaptation.

First off, the "Likes" system on vBulletin.org is custom and does not use any other hacks- however it is too custom to be released. Instead you can modify an existing mod to do mostly the same thing.

Several people have asked me for info on how to do this so I figured I'd write it up and post it here.

You can see what it looks like on my live forum: http://www.juot.net/forums/showthread.php?t=60059



You need the latest version Abe1's Post Thank You Hack (7.7): Here.

What you can see above was done with this mod plus some phrase changes and template edits, and an optional plugin edit.

So step 1 is make sure you have the ?Thank You? mod installed and working.

Step 2 is to change the following phrases. In Admin CP use Phrase Manager to "translate" these phrases from "Thank You" to "Like(s)":

You can of course use your own translations but this is what I used-

Phrase Name | Translation:
post_thanks_already | You have already liked this post!
post_thanks_remove_user | Remove Your Like
post_thanks_search | Find All Liked Posts
post_thanks_search_user | Find all liked posts by {1}
post_thanks_search_user_gave | Find all posts liked by {1}
post_thanks_thanked_post | Liked Post
post_thanks_thanks | Likes
post_thanks_time_post | Liked 1 Time in 1 Post
post_thanks_times_post | Liked {1} Times in 1 Post
post_thanks_times_posts | Liked {1} Times in {2} Posts
post_thanks_total_thanks | Total Likes
post_thanks_user_says | The Following User Likes This Post:
post_thanks_users_say | The Following {1} Users Like This Post:

Some of the above we won't actually use in my implementation but best to fix them all to be consistent.

Step 3:

At this point we need to have a "like.png" file in your images/buttons/ directory and the button directory for every custom style you have, if any. I will attach a couple of options but consider finding or making one unique to your forum.

Step 4:

Now we have to edit a couple of templates.

Edit the template: post_thanks_button

Replace it all with this:

Code:
<a href="post_thanks.php?$session[sessionurl]do=post_thanks_add&amp;p=$post[postid]&amp;securitytoken=$bbuserinfo[securitytoken]" id="post_thanks_button_$post[postid]"<if condition="$vboptions[disable_ajax] != 2"> onclick="return post_thanks_give($post[postid], <if condition="$vboptions[post_groan_integrate]">true<else />false</if>);"</if> <if condition="$display_thanks_image == 'none'">style="display:none"</if> rel="nofollow"><img src="$stylevar[imgdir_button]/like.png" alt="Like This Post" border="0" /></a>
Note: The above template will work correct if you use the "Post Groan Hack" which I also use. You can convert the "Post Groan Hack" into an "dis-like" system basiclly the same way we are changing "Thank You" to "Likes."


Edit the template: post_thanks_postbit_legacy OR post_thanks_postbit (whichever postbit you use)

Replace it all with this:

Code:
<div style="background-color: #CAEBDA; border: 2px ridge #7BBA99; border-width: 2px 2px 2px 2px; padding: 2px; width:99%; margin: 0px auto 0px auto; -webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px; margin-top:auto; margin-bottom:0px;">

<table border="0" width="100%">
<tr>
<td width="100">
<strong>Likes: ($post[post_thanks_amount_formatted])</strong><br />
				
</td><td>
<div style="float:left;">$post[post_thanks_bit]</div> <div style="float:right;"><if condition="$bbuserinfo['usergroupid'] == 6"><a href="post_thanks.php?do=post_thanks_remove_all&amp;p=$post[postid]"<if condition="$vboptions[disable_ajax] != 2"> onclick="return post_thanks_remove_all($post[postid], <if condition="$vboptions['post_groan_integrate']">true<else />false</if>);"</if> rel="nofollow">Delete All</a></if><if condition="$bbuserinfo['usergroupid'] == 6 AND $post['show_thanks_remove_option']"> | </if><if condition="$post['show_thanks_remove_option']"><a href="post_thanks.php?do=post_thanks_remove_user&amp;p=$post[postid]"<if condition="$vboptions['disable_ajax'] != 2"> onclick="return post_thanks_remove_user($post[postid], <if condition="$vboptions['post_groan_integrate']">true<else />false</if>);"</if> rel="nofollow">Unlike</a></if></div>
</td></tr></table>
</div>

At this point you should have a nice light-green "Like" box appearing below each post someone "Likes." You might want to stop here.

The last steps are only if you want to integrate the Like box INTO the posts like on my forum.

If you do the next step is pretty easy-

In Admin CP -> Plugin Manager, edit the plugin: Post Thank You Hack on hook: postbit_display_start

Find the line:

Code:
eval('$template_hook[postbit_end] .= " ' . fetch_template('post_thanks_box') . '";');
and change it to:

Code:
eval('$template_hook[postbit_signature_end] .= " ' . fetch_template('post_thanks_box') . '";');
OK This will move the "Like" box into the actual post table instead of below it.

Again this is a good place to stop if you are happy.

However there is one more template edit I did to keep the Like Box inside the post but at the very bottom of it regardless how short the post might be. In this case we must edit the postbit_legacy template. (I don't use the regular postbit template so I don't have any further instructions for people who use regular postbit. The following is ONLY for postbit_legacy.)

IMPORTANT- Copy all of your postbit_legacy template to a text file and save it as a backup in case you make an error or the instructions don't work for you. You can also "Revert" the template but that will undo ALL customizations you may have made.

Find in postbit_legacy:

Code:
<td class="alt2" width="175" style="border: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]; border-top: 0px; border-bottom: 0px">
Change it to:

Code:
<td class="alt2" rowspan="2" width="175" style="border: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]; border-top: 0px; border-bottom: 0px">
Find:

Code:
$template_hook[postbit_signature_end]
And delete it.

Find:

Code:
		<!-- / edit note -->
		</if>

	</td>
</tr>

Add BELOW it:

Code:
<tr>
<td class="alt1" valign="bottom">
$template_hook[postbit_signature_end]
</td>
</tr>
----

And that should do it.

Of course you are encouraged to make some customizations... Most of what you'll want to change is in the top part of the post_thanks_postbit_legacy template. The background color, border style, and the like are all controlled by this code:

Code:
<div style="background-color: #CAEBDA; border: 2px ridge #7BBA99; border-width: 2px 2px 2px 2px; padding: 2px; width:99%; margin: 0px auto 0px auto; -webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px; margin-top:auto; margin-bottom:0px;">
On my forum I actually use a background image texture but did not include it here as it is an unnecessary complication.

Feel free to play around and tweak the box to your liking. :up:
Attached Images
File Type: jpg Likes_ss.jpg (313.7 KB, 0 views)
Attached Files
File Type: txt Like System Converion by BOP5.txt (6.1 KB, 138 views)
Reply With Quote
  #42  
Old 07-20-2011, 12:54 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I really can't test it on 4.x right now. I know it works fine on 3.8. I would revert back to the "Thank You" hack and see if it works then- that would confirm a bug with the changed code or just a limitation of the mod itself.
Reply With Quote
  #43  
Old 07-20-2011, 01:16 AM
Juggernaut Juggernaut is offline
 
Join Date: Dec 2009
Location: California
Posts: 589
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BirdOPrey5 View Post
I really can't test it on 4.x right now. I know it works fine on 3.8. I would revert back to the "Thank You" hack and see if it works then- that would confirm a bug with the changed code or just a limitation of the mod itself.
After checking the default postbit_display_complete plugin, it seems to be a bug with the changed code, as the reputation does work with the default code. Fixed, it seems I hadn't updated the code correctly, it was totally my fault.
Reply With Quote
  #44  
Old 07-21-2011, 12:37 PM
Post Reader's Avatar
Post Reader Post Reader is offline
 
Join Date: Nov 2009
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

BOP the problem is still there... AJAX feature is not working... when ever i click on the like button the page refreshes which in post thank you hack was not the case...

any solution?
Reply With Quote
  #45  
Old 07-21-2011, 01:04 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Post Reader View Post
BOP the problem is still there... AJAX feature is not working... when ever i click on the like button the page refreshes which in post thank you hack was not the case...


any solution?
I suggest reverting back to the original Post Thank You Hack (re-install if you must and revert the templates) and see if AJAX is working before these edits are made.
Reply With Quote
  #46  
Old 07-21-2011, 03:04 PM
Post Reader's Avatar
Post Reader Post Reader is offline
 
Join Date: Nov 2009
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

have totally re installed the product but will try again now... let me do this, i'll get back to you... thank you

--------------- Added [DATE]1311308942[/DATE] at [TIME]1311308942[/TIME] ---------------

now its working fine... i have re-uploaded all files again and then imported the product.. Thanx BOP
Reply With Quote
  #47  
Old 07-24-2011, 01:08 AM
Juggernaut Juggernaut is offline
 
Join Date: Dec 2009
Location: California
Posts: 589
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Tasking Mickey View Post
I was just about to mention that, if your forum has lets say, 100 members, and you import the likes system, something like here, it would show

Likes (12): Tasking Mickey, Bird0Prey5, Lynne, Princetoon and 15 others

The 15 others, would show the other people who liked that post, it'd be much better, since it won't take up the whole post with like 20 usernames in the like box.
This would be nice, if posible. Only thing is, I don't think the vbulletin 4 version of the thanks system keeps track of the likes given and received, like the likes system here on vbulletin.org. Still way better than the original layout, in my opinion.
Reply With Quote
  #48  
Old 07-29-2011, 10:02 PM
NTMID8 NTMID8 is offline
 
Join Date: Feb 2004
Posts: 187
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by michal72 View Post
I have modified a little bit Joe's proposal to work with vb4
The Likes box is centered under the post. How can I make it aligned left with the post and signature?

Also, I can clearly see where to change the width of the box, colors, etc, but where do I change the font and size of the text within the box?
Reply With Quote
  #49  
Old 07-30-2011, 01:31 AM
Juggernaut Juggernaut is offline
 
Join Date: Dec 2009
Location: California
Posts: 589
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by michal72 View Post
I have modified a little bit Joe's proposal to work with vb4

Change post_thanks_box template to:

PHP Code:
<div <vb:if condition="!$post_thanks_box == 1"style="background-color: #f2f6f8; border: 1px ridge #417394; border-width: 1px 1px 1px 1px; padding: 2px; width:92%; margin: 

0px auto 0px auto; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; margin-top:10px; margin-bottom:0px;display:none" 
<vb:else /> 
style="background-color: #f2f6f8; border: 1px ridge #417394; border-width: 1px 1px 1px 1px; padding: 2px; width:92%; margin: 0px auto 0px auto; -webkit-border-radius: 5px; -

moz-border-radius: 5px; border-radius: 5px; margin-top:10px; margin-bottom:0px;"
</vb:if> id="post_thanks_box_{vb:raw post.postid}">
{
vb:raw post_thanks_box}
</
div
In posbit_legacy template find:
PHP Code:
<vb:if condition="$show['postedited'] || $post['signature']"
and add before:

PHP Code:
{vb:raw template_hook.postbit_messagearea_end
In Admin CP -> Plugin Manager, edit the plugin: Post Thank You Hack on hook: postbit_display_complete

Find:
PHP Code:
$template_hook['postbit_end'] .= $templater->render(); 
and replace with:
PHP Code:
    $template_hook['postbit_messagearea_end'] .= $templater->render(); 
You can also modify window's content:

In post_thanks_postbit template replace:

PHP Code:
    <h2 class="<vb:if condition="!$vboptions['legacypostbit']">post</vb:if>title">
        <
vb:if condition="$post['post_thanks_amount'] == 1">
            {
vb:rawphrase post_thanks_user_says, {vb:raw post.username}}
        <
vb:else />
            {
vb:rawphrase post_thanks_users_say, {vb:raw post.post_thanks_amount_formatted}, {vb:raw post.username}}
        </
vb:if>
    </
h2>
    <
div class="content">
        <
div id="post_thanks_bit_{vb:raw post.postid}">
            <
blockquote class="postcontent restore">
                {
vb:raw post.post_thanks_bit}
            </
blockquote>
        </
div>
    </
div
with:
PHP Code:
    <div class="content">
        <
div id="post_thanks_bit_{vb:raw post.postid}">
            <
blockquote class="postcontent restore">
                <
strong><vb:if condition="$post['post_thanks_amount'] == 1">
            {
vb:rawphrase post_thanks_user_says, {vb:raw post.username}}
        <
vb:else />
            {
vb:rawphrase post_thanks_users_say, {vb:raw post.post_thanks_amount_formatted}, {vb:raw post.username}}
        </
vb:if>
 </
strong>{vb:raw post.post_thanks_bit}
            </
blockquote>
        </
div>
    </
div
BR
This tutorial is exellent, but I've found that I can't change the background color or size of the post thanks box, no matter where I change the code. Has anybody else been able to make changes to the post thanks display?
Reply With Quote
  #50  
Old 07-30-2011, 05:34 AM
michal72 michal72 is offline
 
Join Date: Nov 2010
Posts: 213
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Juggernaut View Post
This tutorial is exellent, but I've found that I can't change the background color or size of the post thanks box, no matter where I change the code. Has anybody else been able to make changes to the post thanks display?
To be able to do it, first you have to modify post_thanks_postbit template.
Please try change it to:
PHP Code:
<vb:if condition="$bbuserinfo['usergroupid'] == 6 || $post['show_thanks_remove_option']">
    <
div class="smallfont" style="float:{vb:stylevar right}">
        <
vb:if condition="$bbuserinfo['usergroupid'] == 6">
            <
a href="post_thanks.php?do=post_thanks_remove_all&amp;p={vb:raw post.postid}"<vb:if condition="$vboptions['disable_ajax'] != 2"onclick="return post_thanks_remove_all({vb:raw post.postid}, <vb:if condition="$vboptions['post_groan_integrate']">true<vb:else />false</vb:if>);"</vb:if> rel="nofollow">{vb:rawphrase post_thanks_remove}</a>
        </
vb:if>
        <
vb:if condition="$bbuserinfo['usergroupid'] == 6 && $post['show_thanks_remove_option']">
            |
        </
vb:if>
        <
vb:if condition="$post['show_thanks_remove_option']">
            <
a href="post_thanks.php?do=post_thanks_remove_user&amp;p={vb:raw post.postid}"<vb:if condition="$vboptions['disable_ajax'] != 2"onclick="return post_thanks_remove_user({vb:raw post.postid}, <vb:if condition="$vboptions['post_groan_integrate']">true<vb:else />false</vb:if>);"</vb:if> rel="nofollow">{vb:rawphrase post_thanks_remove_user}</a>
        </
vb:if>
    </
div>
    </
vb:if>
 
    <
div class="content">
        <
div id="post_thanks_bit_{vb:raw post.postid}">
            <
blockquote class="postcontent restore">
                <
strong><vb:if condition="$post['post_thanks_amount'] == 1">
            {
vb:rawphrase post_thanks_user_says, {vb:raw post.username}}
        <
vb:else />
            {
vb:rawphrase post_thanks_users_say, {vb:raw post.post_thanks_amount_formatted}, {vb:raw post.username}}
        </
vb:if>
 </
strong>{vb:raw post.post_thanks_bit}
            </
blockquote>
        </
div>
    </
div
regards

PS. An appendix to post: https://vborg.vbsupport.ru/showpost....7&postcount=35
Reply With Quote
2 благодарности(ей) от:
Juggernaut, smimosmile
  #51  
Old 07-30-2011, 07:00 AM
Juggernaut Juggernaut is offline
 
Join Date: Dec 2009
Location: California
Posts: 589
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by michal72 View Post
To be able to do it, first you have to modify post_thanks_postbit template.
Please try change it to:
PHP Code:
<vb:if condition="$bbuserinfo['usergroupid'] == 6 || $post['show_thanks_remove_option']">
    <
div class="smallfont" style="float:{vb:stylevar right}">
        <
vb:if condition="$bbuserinfo['usergroupid'] == 6">
            <
a href="post_thanks.php?do=post_thanks_remove_all&amp;p={vb:raw post.postid}"<vb:if condition="$vboptions['disable_ajax'] != 2"onclick="return post_thanks_remove_all({vb:raw post.postid}, <vb:if condition="$vboptions['post_groan_integrate']">true<vb:else />false</vb:if>);"</vb:if> rel="nofollow">{vb:rawphrase post_thanks_remove}</a>
        </
vb:if>
        <
vb:if condition="$bbuserinfo['usergroupid'] == 6 && $post['show_thanks_remove_option']">
            |
        </
vb:if>
        <
vb:if condition="$post['show_thanks_remove_option']">
            <
a href="post_thanks.php?do=post_thanks_remove_user&amp;p={vb:raw post.postid}"<vb:if condition="$vboptions['disable_ajax'] != 2"onclick="return post_thanks_remove_user({vb:raw post.postid}, <vb:if condition="$vboptions['post_groan_integrate']">true<vb:else />false</vb:if>);"</vb:if> rel="nofollow">{vb:rawphrase post_thanks_remove_user}</a>
        </
vb:if>
    </
div>
    </
vb:if>
 
    <
div class="content">
        <
div id="post_thanks_bit_{vb:raw post.postid}">
            <
blockquote class="postcontent restore">
                <
strong><vb:if condition="$post['post_thanks_amount'] == 1">
            {
vb:rawphrase post_thanks_user_says, {vb:raw post.username}}
        <
vb:else />
            {
vb:rawphrase post_thanks_users_say, {vb:raw post.post_thanks_amount_formatted}, {vb:raw post.username}}
        </
vb:if>
 </
strong>{vb:raw post.post_thanks_bit}
            </
blockquote>
        </
div>
    </
div
regards

PS. An appendix to post: https://vborg.vbsupport.ru/showpost....7&postcount=35
Thank you Michal, but the plugin edit you provided seems to have stopped working with vbulletin 4.1.5, I can't get the edit to funcion.

Edit: it still works great, I had overlooked one of the template edits.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:22 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05376 seconds
  • Memory Usage 2,466KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (10)bbcode_code
  • (9)bbcode_php
  • (7)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (48)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (2)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete