我使用组件 K2,它是投票/评级系统。目前它以百分比的形式显示评分,并带有一些 CSS 来查看星星。但是我不想显示星星,而是说例如 4.5/5
这是查看它的代码:
<?php if($this->item->params->get('catItemRating')): ?>
<div id="catItemRatingBlock">
<div class="itemRatingForm">
<ul class="itemRatingList">
<li class="itemCurrentRating" id="itemCurrentRating<?php echo $this->item->id; ?>" style="width:<?php echo $this->item->votingPercentage; ?>%;"></li>
<li><a href="#" rel="<?php echo $this->item->id; ?>" class="one-star">1</a></li>
<li><a href="#" rel="<?php echo $this->item->id; ?>" class="two-stars">2</a></li>
<li><a href="#" rel="<?php echo $this->item->id; ?>" class="three-stars">3</a></li>
<li><a href="#" rel="<?php echo $this->item->id; ?>" class="four-stars">4</a></li>
<li><a href="#" rel="<?php echo $this->item->id; ?>" class="five-stars">5</a></li>
</ul>
</div>
</div>
<?php endif; ?>
这是在“com_k2/models/item.php”中找到的代码:
function getVotesPercentage($itemID = NULL)
{
$mainframe = &JFactory::getApplication();
$user = JFactory::getUser();
$db = &JFactory::getDBO();
$xhr = false;
$result = 0;
if (is_null($itemID))
{
$itemID = JRequest::getInt('itemID');
$xhr = true;
}
$vote = K2ModelItem::getRating($itemID);
if (!is_null($vote) && $vote->rating_count != 0)
{
$result = number_format(intval($vote->rating_sum) / intval($vote->rating_count), 2) * 20;
}
if ($xhr)
{
echo $result;
$mainframe->close();
}
else
return $result;
}
我该怎么办?