Like thread's first post from Thread List?

Đoàn Hoàng Nam

Active member
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.webp

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.webp

Sorry for my bad English :(
 
$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)
 
$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 !
 
Back
Top Bottom