The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
How to turn the "Post Thank You" hack into a "Likes" system similar to vBulletin.org
BirdOPrey5
Join Date: Jun 2008
Posts: 10,610
The details of my life are quite inconsequential. New York
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&p=$post[postid]&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> 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&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&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') . '";'); Code:
eval('$template_hook[postbit_signature_end] .= " ' . fetch_template('post_thanks_box') . '";'); 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"> Code:
<td class="alt2" rowspan="2" width="175" style="border: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]; border-top: 0px; border-bottom: 0px"> Code:
$template_hook[postbit_signature_end] 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;"> Feel free to play around and tweak the box to your liking. :up: |
#152
|
|||
|
|||
Has anyone been able to integrate this hack with vB's notification system? So for example, every time a user receives a "thanks" or "thumbs up" they'd receive a notification just like they would if they received, say, a VM? If so, how was this accomplished?
|
#153
|
||||
|
||||
|
#154
|
|||
|
|||
Quote:
|
Благодарность от: | ||
blind-eddie |
#155
|
|||
|
|||
OK, maybe I am a little late in this, but I've installed it, like it but I can't make the box move inside the post area, no matter what I tried.
I can make it move inside but: - If I put it below the signature, then all the buttons at the bottom of the post get mangled. - If I put it above the signature, the signature doesn't show and the buttons get mangled again. - If I put it above the post, everything disappears, and the buttons get screwed up again. I am using vB 4.2.2 and the postbit (not postbit_legacy) template. Ideas? --------------- Added [DATE]1441621426[/DATE] at [TIME]1441621426[/TIME] --------------- OK, I've managed to solve the issue I had with this hack, or at least, I've managed to move the statistics box inside the postbit area, below the signature. The offending part, was the post_thanks_box template. As it was, when I installed the hack, it looked like this: Code:
<li class="postbit<vb:if condition="$vboptions['legacypostbit']">legacy</vb:if> postbitim" id="post_thanks_box_{vb:raw post.postid}"<vb:if condition="!$post_thanks_box == 1"> style="display:none"</vb:if>> {vb:raw post_thanks_box} </li> 1. Change your post_thanks_box template, to: Code:
<div class="postbit<vb:if condition="$vboptions['legacypostbit']">legacy</vb:if> postbitim" id="post_thanks_box_{vb:raw post.postid}"<vb:if condition="!$post_thanks_box == 1"> style="display:none"</vb:if>> {vb:raw post_thanks_box} </div> Code:
require_once(DIR . '/includes/functions_post_thanks.php'); if (!(defined('LOCATION_BYPASS')) && !(post_thanks_off($this->thread['forumid'], $this->post, $this->thread['firstpostid'], THIS_SCRIPT))) { global $ids; $thanks = fetch_thanks($this->post['postid'], $ids); if (thanked_already($this->post) && $this->registry->options[post_thanks_delete_own]) { $this->post['show_thanks_remove_option'] = true; } if ($this->post['post_thanks_amount'] > 0 && $this->thread['isdeleted'] == 0) { $this->post['post_thanks_bit'] = fetch_thanks_bit($this->thread['forumid'], $thanks); $this->post['post_thanks_user'] = $post_thanks_user; $this->post['post_thanks_amount_formatted'] = vb_number_format($this->post['post_thanks_amount']); $post_thanks_box = fetch_post_thanks_template($this->post); } $templater = vB_Template::create('post_thanks_box'); $templater->register('post', $post); $templater->register('post_thanks_box', $post_thanks_box); $template_hook['postbit_signature_end'] .= $templater->render(); } if ($this->registry->userinfo['userid'] != 0 && !(defined('LOCATION_BYPASS')) && !(post_thanks_off($thread['forumid'], $post, $thread['firstpostid'], THIS_SCRIPT))) { $display_thanks_image = 'none'; if (can_thank_this_post($post, $thread['isdeleted']) && !thanked_already($post)) { $display_thanks_image = ''; } $templater = vB_Template::create('post_thanks_button'); $templater->register('post', $post); $templater->register('display_thanks_image', $display_thanks_image); $template_hook['postbit_controls'] .= $templater->render(); } if ($this->registry->options['post_thanks_show_stats_postbit']) { $post['post_thanks_user_amount_formatted'] = vb_number_format($post['post_thanks_user_amount']); $post['post_thanks_thanked_times_formatted'] = vb_number_format($post['post_thanks_thanked_times']); $post['post_thanks_thanked_posts_formatted'] = vb_number_format($post['post_thanks_thanked_posts']); $templater = vB_Template::create('post_thanks_postbit_info'); $templater->register('post', $post); $template_hook['postbit_userinfo_right_after_posts'] .= $templater->render(); } Code:
<div style="background-color: #E1E4F3; border: 2px ridge #7BBA99; ; border-width: 2px 2px 2px 2px; padding: 2px; width:100%; margin: 0px auto 0px auto; margin-top:auto; margin-bottom:0px;"> <table border="0" width="100%"> <tr> <td width="100"> <strong><b>Likes ($post[post_thanks_amount_formatted]) :</b></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&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&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> <br /> Code:
<h5 class="subsubsectionhead">{vb:rawphrase post_thanks_total_thanks}</h5> <dl class="stats"> <dt>{vb:rawphrase post_thanks_total_thanks} given</dt> <dd>{vb:raw userinfo.post_thanks_user_amount_formatted} -- <a href="post_thanks.php?{vb:raw session.sessionurl}do=findthanks_user_gave&u={vb:raw userinfo.userid}">{vb:rawphrase post_thanks_search_user_gave, {vb:raw userinfo.username}}</a></dd> </dl> <dl class="stats"> <dt>{vb:rawphrase post_thanks_total_thanks} received</dt> <dd><vb:if condition="$userinfo[post_thanks_thanked_times] == 1"> {vb:rawphrase post_thanks_time_post} <vb:else /> <vb:if condition="$userinfo[post_thanks_thanked_posts] == 1"> {vb:rawphrase post_thanks_times_post, {vb:raw userinfo.post_thanks_thanked_times_formatted}} <vb:else /> {vb:rawphrase post_thanks_times_posts, {vb:raw userinfo.post_thanks_thanked_times_formatted}, {vb:raw userinfo.post_thanks_thanked_posts_formatted}} </vb:if> </vb:if> -- <a href="post_thanks.php?{vb:raw session.sessionurl}do=findthanks&u={vb:raw userinfo.userid}">{vb:rawphrase post_thanks_search_user, {vb:raw userinfo.username}}</a></dd> </dl> I hope this helps some people here. |
#156
|
|||
|
|||
Using the hack from post #35, I'm having a few issues:
1) I click like, then "remove this like", and the page refreshes saying: "user, you do not have permission to access this page. This could be due to one of several reasons:" 2) Also getting a weird box (I think for the collapse, but that is turned off and it still shows). What's the best way to fix that? https://www.dropbox.com/s/sk6hcn8789...58.45.png?dl=0 3) When I click "thanks" on a post with other thanks, and then remove my thanks, it collapses the box with other likes so I can't see them until I refresh the page. Any help resolving this would be appreciated. Thanks. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|