Hi,
I use Joomla’s Jreviews for my rating website and there’s this function that calculates the overall ratings for any listing
function drawStars($rating, $scale, $graphic, $type)
{
$round_to = $scale > 10 ? 0 : 1;
$rating_graphic = $graphic ? 'rating_star_' : 'rating_bar_';
$class = $rating_graphic . $type; // builds the class based on graphic and rating type
$ratingPercent = number_format(($rating/$scale)*100,0);
if ($rating > 0) {
return "<div class=\\"$class\\"><div style=\\"width:{$ratingPercent}%;\\"> </div></div>";
} elseif ($this->no_rating_text) {
return $this->no_rating_text;
} else {
return "<div class=\\"$class\\"><div style=\\"width:0%;\\"> </div></div>";
}
}
Now, I want to include picture of a fresh tomato or a rotten tomato based on the overall rating score. How can I do so…? Can you please make me understand this code? Will not simple if then else solve this problem?
Please guide me guys…