XF 1.4 Displaying post likes counter w/ dynamic updating?

mike406

Member
Hi all. We've made a small template modification to show the # of post likes (if any exist) next to the Like/Unlike link for posts. Example image below.

6719e07b1be4cf36fa156cb4d0a13776.png


What I would like to add so it's more fluid, is when someone goes to Like or Unlike the post that the number next to View Likes be dynamically updated plus or minus one accordingly. Is there by chance any elegant way I could do this in the post template to achieve this? Or am I just better off writing some jQuery/Javascript myself?

The current template code that shows View Likes: X is just this bit here.
Code:
<xen:if is="{$post.likes}">
    <a href="{xen:link 'posts/likes', $post}" class="item control">{xen:phrase khflare_view_likes, 'count={xen:number $post.likes}'}</a>
</xen:if>

Thank you for any input! :)
 
  • Like
Reactions: arn
I don't know a lot about this because I haven't looked at it before - but as you can see, when liking a post on XF, some AJAX/JS is called and a "likes box" is added below the post. I'd do some investigation into that and see if you can add your own JS there to increment / decrement the like counter.
 
Top Bottom