Tech Support Posted July 30, 2017 Share Posted July 30, 2017 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.