【问题标题】:Getting K2 extra fields and rating into the search results, generic.php在搜索结果中获取 K2 额外字段和评分,generic.php
【发布时间】:2013-01-23 06:31:00
【问题描述】:

我尝试在搜索结果中显示标签、项目评级和 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

【问题讨论】:

  • 尝试以 k2 形式发帖。他们也许能更好地帮助你!

标签: joomla tags rating joomla-k2


【解决方案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-02-23
    • 2020-10-04
    • 2014-11-01
    • 2013-06-18
    • 2013-06-24
    • 2012-12-27
    • 1970-01-01
    • 2011-07-18
    • 2015-02-15
    相关资源
    最近更新 更多