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

Like thread's first post from Thread List?

#1
How can I create a like button in Thread List that when I click on it => I like that thread's first post?

I would be like this
Untitled.png

I tried this code but it didn't working
Code:
<xen:if is="{$thread.canLike}">
                <a href="{xen:link posts/like, $thread}" class="LikeLink item control {xen:if $thread.like_date, unlike, like}" data-container="#likes-post-{$thread.post_id}"><span></span><span class="LikeLabel">{xen:if $thread.like_date, {xen:phrase unlike}, {xen:phrase like}}</span></a>
            </xen:if>
It says there's an error
Untitled2.png

Sorry for my bad English :(
 
#2
$thread has element 'first_post_id'

You can use such construction:
HTML:
<xen:if is="{$thread.canLike}">
                <a href="{xen:link posts/like, '', 'post_id={$thread.first_post_id}'}" class="LikeLink item control" data-container="#likes-post-{$thread.first_post_id}"><span></span><span class="LikeLabel">{xen:if $thread.like_date, {xen:phrase unlike}, {xen:phrase like}}</span></a>
            </xen:if>
But you can't check 'you already liked this post or no'

Sorry for my bad English :(
(2)
 
#3
$thread has element 'first_post_id'

You can use such construction:
HTML:
<xen:if is="{$thread.canLike}">
                <a href="{xen:link posts/like, '', 'post_id={$thread.first_post_id}'}" class="LikeLink item control" data-container="#likes-post-{$thread.first_post_id}"><span></span><span class="LikeLabel">{xen:if $thread.like_date, {xen:phrase unlike}, {xen:phrase like}}</span></a>
            </xen:if>
But you can't check 'you already liked this post or no'


(2)
Thanks for the solution !