Jump to content

Theme customization: showing number of likes and / or dislikes


Tech Support

Recommended Posts

Rating in KVS is a number from 0 to 5 due to historical reasons. Initially it was a 5-star rating where users could vote not just as "like" or "dislike", but also use other rating values.

In modern themes almost everybody is using likes or dislikes. So do KVS themes. However internally the rating is still calculated as a plain number, where "like" is a 5-star vote and "dislike" is a 0-star vote. By default rating is displayed as % amount of likes using this code:

Inside list block (means for each video / album / model / etc. in the list):

{{assign var="rating" value="`$item.rating/5*100`"}}
{{if $rating>100}}{{assign var="rating" value="100"}}{{/if}}
{{$rating}}%

 

Inside view block:

{{assign var="rating" value="`$data.rating/5*100`"}}
{{if $rating>100}}{{assign var="rating" value="100"}}{{/if}}
{{$rating}}%

 

If you want to change this with the number of likes and dislikes, or show them additionally to % rating, you can use this code:

Inside list block (means for each video / album / model / etc. in the list):

{{assign var="likes" value=0}}
{{assign var="dislikes" value=0}}
{{if $item.rating>0}}
{{assign var="likes" value=$item.rating*$item.rating_amount/5|replace:",":"."|round}}
{{assign var="dislikes" value=$item.rating_amount-$likes}}
{{/if}}
{{$likes}} likes and {{$dislikes}} dislikes

 

Inside view block:

{{assign var="likes" value=0}}
{{assign var="dislikes" value=0}}
{{if $data.rating>0}}
{{assign var="likes" value=$data.rating*$data.rating_amount/5|replace:",":"."|round}}
{{assign var="dislikes" value=$data.rating_amount-$likes}}
{{/if}}
{{$likes}} likes and {{$dislikes}} dislikes
 
  • Like 1
Link to comment
Share on other sites

  • 2 years later...
5 hours ago, Tanjiro said:

I see user can't change like or dislike once they chose, it's said "IP already voted" . How to fix that ?

This is not possible in KVS. We will probably fix that when come to migrating rating to the nextgen architecture, for now it is still using the old code.

  • Like 1
Link to comment
Share on other sites

On 3/19/2023 at 6:48 PM, Tech Support said:

This is not possible in KVS. We will probably fix that when come to migrating rating to the nextgen architecture, for now it is still using the old code.

I hope you can include feature that can change up vote/down vote in comment section too in next update

image.png.4ab20e631f7b9ee64f2ec6fcdaa2937f.png

Edited by Tanjiro
Link to comment
Share on other sites

5 hours ago, Tanjiro said:

I hope you can include feature that can change up vote/down vote in comment section too in next update

For now it is not about the next update, but yes, when we come to moving rating \ comments to the nextgen API, we will solve all questions and issues that have been collected during the long time for these topics.

  • Like 1
Link to comment
Share on other sites

  • 10 months later...
On 7/30/2017 at 12:18 PM, Tech Support said:

Rating in KVS is a number from 0 to 5 due to historical reasons. Initially it was a 5-star rating where users could vote not just as "like" or "dislike", but also use other rating values.

In modern themes almost everybody is using likes or dislikes. So do KVS themes. However internally the rating is still calculated as a plain number, where "like" is a 5-star vote and "dislike" is a 0-star vote. By default rating is displayed as % amount of likes using this code:

Inside list block (means for each video / album / model / etc. in the list):

{{assign var="rating" value="`$item.rating/5*100`"}}
{{if $rating>100}}{{assign var="rating" value="100"}}{{/if}}
{{$rating}}%

 

Inside view block:

{{assign var="rating" value="`$data.rating/5*100`"}}
{{if $rating>100}}{{assign var="rating" value="100"}}{{/if}}
{{$rating}}%

 

If you want to change this with the number of likes and dislikes, or show them additionally to % rating, you can use this code:

Inside list block (means for each video / album / model / etc. in the list):

{{assign var="likes" value=0}}
{{assign var="dislikes" value=0}}
{{if $item.rating>0}}
{{assign var="likes" value=$item.rating*$item.rating_amount/5|replace:",":"."|round}}
{{assign var="dislikes" value=$item.rating_amount-$likes}}
{{/if}}
{{$likes}} likes and {{$dislikes}} dislikes

 

Inside view block:

{{assign var="likes" value=0}}
{{assign var="dislikes" value=0}}
{{if $data.rating>0}}
{{assign var="likes" value=$data.rating*$data.rating_amount/5|replace:",":"."|round}}
{{assign var="dislikes" value=$data.rating_amount-$likes}}
{{/if}}
{{$likes}} likes and {{$dislikes}} dislikes
 

I'm sorry but can you be more specific? Where can I change from percentage to number likes and dislike like this

image.png.259545dcca21e23aebec7fa2dc9cf490.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...