Announcement

Collapse
No announcement yet.

Theme customization: showing number of likes and / or dislikes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Theme customization: showing number of likes and / or dislikes

    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):
    Code:
    {{assign var="rating" value="`$item.rating/5*100`"}}
    {{if $rating>100}}{{assign var="rating" value="100"}}{{/if}}
    {{$rating}}%
    Inside view block:
    Code:
    {{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):
    Code:
    {{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:
    Code:
    {{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
    Last edited by Tech Support; 08-23-2017, 11:08 AM.
Working...
X