2

我尝试在搜索结果中显示标签、项目评级和 exztra 字段。我有要显示的标签,但我在评级和额外字段方面失败了。有人可以建议我或给出代码示例吗?这是在 generic.php 中显示标签的代码:

    <?php 
  $tags = K2ModelItem::getItemTags($item->id);
  for ($i=0; $i<sizeof($tags); $i++) {
    $tags[$i]->link = JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name));
  }
  $item->tags=$tags;
    ?>

    <?php if(count($item->tags)): ?>
       <!-- Item tags -->
   <div class="genericItemTagsBlock">
  <span><?php echo JText::_("Tagged under"); ?></span>
  <ul class="genericItemTags">
    <?php foreach ($item->tags as $tag): ?>
    <li><a href="<?php echo $tag->link; ?>"><?php echo $tag->name; ?></a></li>
    <?php endforeach; ?>
  </ul>
    <div class="clr"></div>
     </div>
      <?php endif; ?>

在此先感谢您的帮助!关于寒冷B

4

1 回答 1

1

这对我有用:

$rating_width  = 0;
$vote = K2ModelItem::getRating($item->id);

if (!is_null($vote) && $vote->rating_count != 0) {
    $rating_width = number_format(intval($vote->rating_sum) /  intval($vote->rating_count), 2) * 20;
}

<div class="itemRatingBlock">
<div class="itemRatingForm">
    <ul class="itemRatingList">
    <li class="itemCurrentRating" id="itemCurrentRating<?php echo $item->id; ?>" style="cursor: inherit; width:<?php echo $rating_width;?>%;">
            </li>
    </ul>
</div>

于 2013-06-24T14:26:21.097 回答