Likes JS

silence

Well-known member
So I'm coding up a custom usage of the likes, and it all works so far, however the function in xenforo.js 'XenForo.LikeLink' isn't executing to show the like_summary upon liking or unliking content.

I'm not getting any errors it simply doesn't do the fancy scroll thing upon liking/unliking content.

Are there any examples that describe how to do this, or what can I post to get help with this since I'm not exactly sure what the issue is D:

Thanks!
 
Your controller action should return a view which takes care of loading the likes_summary template, etc.

e.g. XenForo_ViewPublic_Post_LikeConfirmed
 
Your controller action should return a view which takes care of loading the likes_summary template, etc.

e.g. XenForo_ViewPublic_Post_LikeConfirmed
I copied the ProfilePost version as so:

Code:
<?php

class PostComments_ViewPublic_Post_LikeConfirmed extends XenForo_ViewPublic_Base
{
    public function renderJson()
    {
        $message = $this->_params['comment'];

        if (!empty($message['likeUsers']))
        {
            $params = array(
                'message' => $message,
                'likesUrl' => XenForo_Link::buildPublicLink('post/comment-likes', $message, array('comment' => $message['comment_id']))
            );

            $output = $this->_renderer->getDefaultOutputArray(get_class($this), $params, 'post_comment_likes_summary');
        }
        else
        {
            $output = array('templateHtml' => '', 'js' => '', 'css' => '');
        }

        $output += XenForo_ViewPublic_Helper_Like::getLikeViewParams($this->_params['liked']);

        return XenForo_ViewRenderer_Json::jsonEncodeForOutput($output);
    }
}

However it's still not working, the template 'post_comment_likes_summary' is the same as well.
 
I can see also when I use my like, it prints this to js console:
Code:
{"templateHtml":"","css":"","js":"","term":"Unlike","cssClasses":{"like":"-","unlike":"+"},"_visitor_conversationsUnread":"8","_visitor_alertsUnread":"0"}
While a profile post prints this:
Code:
{"templateHtml":"\n\t\n\t<div class=\"likesSummary secondaryContent\">\n\t\t<span class=\"LikeText\">\n\t\t\tYou like this.\n\t\t<\/span>\n\t<\/div>\n","css":{"stylesheets":["likes_summary"],"urlTemplate":"css.php?css=__sentinel__&style=47&dir=LTR&d=1416215382"},"js":"","term":"Unlike","cssClasses":{"like":"-","unlike":"+"},"_visitor_conversationsUnread":"8","_visitor_alertsUnread":"1"}
So I'm unsure what I'm missing D:
 
Ok switching to the template 'likes_summary' fixes the console output but the animation still isn't happening.
 
Ugh every time I post i find a solution quickly...
Had something to do with:
Code:
data-container="#likes -ps-{$comment.comment_id}"
and changing it to:
Code:
data-container="#likes-{$comment.comment_id}"
fixes the issue.

No idea why though D:
 
Back
Top Bottom