Answer the question
In order to leave comments, you need to log in
DLE how to display the rating as a percentage?
Hello, please tell me what and where to prescribe to display the rating of the news as a percentage?
Now a 5-star rating is connected, I need to leave it, but under it, for example, in another place, display a scale with a percentage, for example, 87%.
Answer the question
In order to leave comments, you need to log in
In general, I figured out how to do it, you need in the files /engine/modules/show.full.php and short.php after:
$tpl->set( '{vote-num}', "".$row['vote_num' ]."");
Insert:
$rating_num = str_replace(",", ".", round($row['rating'] / max(1, $row['vote_num']),1));
$tpl->set('{rating_num}', $rating_num);
$rating_proc = ($rating_num * 2) * 10;
$tpl->set( '{rating_proc}', $rating_proc);
This will immediately give us 2 types of rating:
1) In the form of 4.5 ({rating_num})
2) In the form of 90 - percent ({rating_proc})
This works if you have the rating mode in the form of 5 (five) stars.
"Layout" here at what?
webrambo.ru/103-rating-v-procentah-dlya-kratkoy-n...
to display the news rating as a percentage?
x = максимальный рейтинг * рейтинг новости / 100
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question