1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.4 Displaying post likes counter w/ dynamic updating?

Discussion in 'Styling and Customization Questions' started by mike406, Jan 25, 2015.

  1. mike406

    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.


    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.
    <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>
    Thank you for any input! :)
    arn likes this.
  2. Adam K M

    Adam K M Active Member

    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.
  3. Amaury

    Amaury Well-Known Member

    @Russ, @Steve F, perhaps you could shine some light on this? :)

Share This Page