Post Ratings - taking likes to the next level [Deleted]

Luke F

Well-known member
DBTech Adv. Post Thanks/Like import:

Code:
insert ignore into XENFORO_DB_NAME.dark_postrating select null, contentid, userid, receiveduserid, if(varname = 'thanks', THANKS_RATING_ID, if(varname = 'dislike', DISLIKE_RATING_ID, 1)), dateline from VBULLETIN_DB_NAME.dbtech_thanks_entry


___________________________________________________________



Post Thank You Hack import:

Code:
insert ignore into XENFORO_DB_NAME.dark_postrating select null, postid, userid, content_userid, THANKS_RATING_ID, date from VBULLETIN_DB_NAME.post_thanks

For both queries you must import keeping source IDs and replace the bits in caps with the relevant values. Once done, run Recount Ratings in your Admin CP.



Alternative Post Thank You hack import for where your table does not contain content_userid:

Code:
insert ignore into XENFORO_DB_NAME.dark_postrating select null, postid, userid, null, THANKS_RATING_ID, date from VBULLETIN_DB_NAME.post_thanks

Code:
update dark_postrating r set r.rated_user_id = (select p.user_id from xf_post p where p.post_id = r.post_id) where r.rated_user_id is null


___________________________________________________________


Delete all ratings made by a user:

Code:
delete from dark_postrating where user_id = x
(Then run recount ratings.)

___________________________________________________________


Delete all ratings received by a user (aka reset a user's rating scores):

Code:
delete from dark_postrating where rated_user_id = x
(Then run recount ratings.)

___________________________________________________________


Delete all negative ratings made by a user:

Code:
delete pr
from dark_postrating pr
left join dark_postrating_ratings r on pr.rating = r.id
where pr.user_id = x and r.type = -1
(Then run recount ratings.)

___________________________________________________________


Delete all negative ratings received by a user:

Code:
delete pr
from dark_postrating pr
left join dark_postrating_ratings r on pr.rating = r.id
where pr.rated_user_id = x and r.type = -1
(Then run recount ratings.)


___________________________________________________________


XenPorta 2 support:



I got this working for xenporta2 now.

If anyone is interested you need to edit the template modification for xenporta and change it to
Code:
Template: EWRporta2_Article_Post

Find: <xen:set var="$messageAfterTemplate">

Replace:
<xen:set var="$messageAfterTemplate">
<xen:hook name="dark_postrating_likes_bar_xenporta" params="{xen:array 'post={$post}','message_id={$messageId}'}" />


___________________________________________________________


Convert like format: (not recommended)

http://xenforo.com/community/thread...the-next-level-paid.28475/page-23#post-344980




___________________________________________________________


Convert ratings to likes: (irreversible; for permanent uninstallations)


  1. Select a rating you would like to convert to XF Likes in Options > Post Ratings > Like rating
  2. Run Recount Ratings
  3. Click cancel once it starts building the rating cache
  4. Repeat steps 1-3 for all ratings you would like to convert to likes


___________________________________________________________


Recounting ratings on extremely large databases (aka if 'recount ratings' in ACP times out):

  1. Follow instructions above to convert like format
  2. http://xenforo.com/community/thread...the-next-level-paid.28475/page-85#post-629004

No longer needed as of version 1.7.0

___________________________________________________________


Font Awesome rating icons (experimental, no support provided):

Update: An alternative user-provided solution is available here: https://xenforo.com/community/threa...he-next-level-paid.28475/page-130#post-926118

Add to EXTRA.css:

Code:
.dark_postrating_textonly { font-family: FontAwesome; font-size: 1.6em; vertical-align: bottom; }

Add a new rating, leaving 'Icon' blank and set 'Title' to the raw unicode character for the desired Font Awesome icon. This can be copy+pasted via inspect element in your web browser:
yca-.png


Note that having an actual title along with the icon is not possible without template modifications. (You could put the name next to the unicode symbol, but it won't have the same rollover caption.)


___________________________________________________________


Anonymous ratings:

To make all ratings on your forum anonymous, simply deny the 'list ratings' permission, and edit the templates news_feed_item_postrating_rate and alert_postrating_rate, changing all instances of:

Code:
       'name={xen:helper username, $user, 'primaryText'}',

To something like:

Code:
       'name=A user',
 
Last edited:
Manual Template Edits:


These template edits are for legacy versions (Post Ratings 1.5.1 and below) ONLY.


Apply this edit to XenForo versions 1.1.2 and 1.1.3 only:
(And any older versions but note that they are not supported anyway)

  • Add this code to the start of the ad_message_below template:
    <xen:hook name="message_below" params="{xen:array 'post={$message}','message_id={$messageId}'}" />

Additionally, apply these edits to versions 1.1.2 - 1.1.5:

  • In member_list_item, (Do not save between these two edits to this template)
    Before: <div class="userInfo">
    Add : <xen:hook name="dark_member_list_info" params="{xen:array 'user={$user}'}">
  • Also in member_list_item,
    Before: <xen:else />
    Add: </xen:hook>
  • (Optional) If you have XenPorta installed, in EWRporta_ArticleMessage,
    Before the final: </li>
    Add: <xen:hook name="message_below" params="{xen:array 'post={$message}','message_id={$messageId}'}" />
 
Last edited:
Nice work.

When you first suggested this I wasn't too interested but now I am seriously considering it.
 
Hey Dark, loving it thus far. I'm trying to add the rating counts to my custom header bar:

IpfpC.png


but they're coming up as zeros. I've tried adding the following in your event listener (though I hate having to edit your code in case of updates):
Code:
        else if ($hookName == 'header_bar_ratings')
        {   
            $params = $template->getParams();
            $params += $hookParams;
            $content .= $template->create('dark_postrating_header_bar', $params);       
        }

but I'm not having any luck. The header_bar_ratings hook is in my custom header_bar template, and the dark_postrating_header_bar template is simply:
Code:
{xen:phrase ratings}: <span style="color:@ratingPositive">+{xen:number $postrating_ratings_total.positive}</span> / {xen:number $postrating_ratings_total.neutral} / <span style="color:@ratingNegative">-{xen:number $postrating_ratings_total.negative}</span>

I'm not too keen on params and the like across templates. :oops: Perhaps you (or anyone?) can point me in the right direction? I have an odd feeling it's something silly and right under my nose...

Thanks
 
I've tried to register to your forum, but captcha don't allow me to register :confused:

I've just tested and not having any issue? Perhaps you just got a bad captcha ;)


Hey Dark, loving it thus far. I'm trying to add the rating counts to my custom header bar:

IpfpC.png


but they're coming up as zeros. I've tried adding the following in your event listener (though I hate having to edit your code in case of updates):
Code:
        else if ($hookName == 'header_bar_ratings')
        {
            $params = $template->getParams();
            $params += $hookParams;
            $content .= $template->create('dark_postrating_header_bar', $params);   
        }

but I'm not having any luck. The header_bar_ratings hook is in my custom header_bar template, and the dark_postrating_header_bar template is simply:
Code:
{xen:phrase ratings}: <span style="color:@ratingPositive">+{xen:number $postrating_ratings_total.positive}</span> / {xen:number $postrating_ratings_total.neutral} / <span style="color:@ratingNegative">-{xen:number $postrating_ratings_total.negative}</span>

I'm not too keen on params and the like across templates. :oops: Perhaps you (or anyone?) can point me in the right direction? I have an odd feeling it's something silly and right under my nose...

Thanks

You need to pass through a user object, so something like this in place of the hook code you've got there:

Code:
            $params = $template->getParams();
            $params += $hookParams;
            $params += array(
                "user" => XenForo_Visitor::getInstance()
            );
            $content .= $template->create('dark_postrating_header_bar', $params);

And also you would need to add your template name to this conditional:

Code:
        } else if($templateName == 'dark_postrating_member' || $templateName == 'dark_postrating_member_totals' || $templateName == 'dark_postrating_member_card'){
 
just bought it ...

i have a rank system based on "likes received" ... do all forms of like increase that "likes received" number ? ... or only the "normal" one ?
 
just bought it ...

i have a rank system based on "likes received" ... do all forms of like increase that "likes received" number ? ... or only the "normal" one ?

You would need to change your rank system to be based on positive ratings received. The likes received is still increased, but only for 'like' ratings.
 
Top Bottom