app/template/default/ProductReview42/Resource/template/default/review.twig line 1

Open in your IDE?
  1. {#
  2. /*
  3.  * This file is part of the ProductReview plugin
  4.  *
  5.  * Copyright (C) 2016 LOCKON CO.,LTD. All Rights Reserved.
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. #}
  11. {% import _self as stars %}
  12. {# 星テキスト生成用マクロ #}
  13. {% macro stars(positive, negative) %}
  14.     {% set positive_stars = ["", "★", "★★", "★★★", "★★★★", "★★★★★"] %}
  15.     {% set negative_stars = ["", "☆", "☆☆", "☆☆☆", "☆☆☆☆", "☆☆☆☆☆"] %}
  16.     {{ positive_stars[positive] }}{{ negative_stars[negative] }}
  17. {% endmacro %}
  18. <script>
  19.     $(function() {
  20.         $('#product_review_area').appendTo($('.ec-layoutRole__main, .ec-layoutRole__mainWithColumn, .ec-layoutRole__mainBetweenColumn'));
  21.         $('#product_review_area .ec-rectHeading').on('click', function() {
  22.             $content = $('#reviewContent');
  23.             if ($content.css('display') == 'none') {
  24.                 $(this).addClass('is_active');
  25.                 $content.addClass('is_active');
  26.                 $content.slideDown(300);
  27.             } else {
  28.                 $(this).removeClass('is_active');
  29.                 $content.removeClass('is_active');
  30.                 $content.slideUp(300);
  31.             }
  32.             return false;
  33.         });
  34.     });
  35. </script>
  36. <!--▼レビューエリア-->
  37. <div id="product_review_area">
  38.     <div class="ec-role">
  39.         {% set positive_avg_star = ProductReviewAvg %}
  40.         {% set negative_avg_star = 5 - positive_avg_star %}
  41.         <div class="_top">
  42.             <p class="ec-rectHeading is_active">
  43.                 <span>{{ 'product_review.front.product_detail.title'|trans }}</span>
  44.                 <!--平均の星の数-->
  45.                 <span class="recommend_average">{{ stars.stars(positive_avg_star, negative_avg_star) }}</span>
  46.                 <!--レビュー数-->
  47.                 <span>({{ ProductReviewCount }})</span>
  48.                 {# <span class="chevron pull-right">
  49.                     <i class="fas fa-angle-up fa-lg"></i>
  50.                 </span> #}
  51.             </p>
  52.             <span class="_btn">
  53.                 <a href="{{ url('product_review_index', { id: Product.id }) }}" class="ec-inlineBtn--action">レビューを書く</a>
  54.             </span>
  55.         </div>
  56.         <div id="reviewContent">
  57.             {% if ProductReviews %}
  58.                 <ul class="review_list">
  59.                     {% for ProductReview in ProductReviews %}
  60.                         <li>
  61.                             <!--星の数-->
  62.                             {% set positive_star = ProductReview.recommend_level %}
  63.                             {% set negative_star = 5 - positive_star %}
  64.                             <p class="recommend_level">
  65.                                 {{ stars.stars(positive_star, negative_star) }}
  66.                             </p>
  67.                             <!--タイトル-->
  68.                             <p class="_title">{{ ProductReview.title }}</p>
  69.                             <p class="recommend_name">
  70.                                 <span>
  71.                                     {% if ProductReview.reviewer_url %}
  72.                                         <a href="{{ ProductReview.reviewer_url }}" rel="ugc nofollow"
  73.                                             target="_blank">{{ 'product_review.front.product_detail.name'|trans({ '%name%': ProductReview.reviewer_name }) }}</a>
  74.                                     {% else %}
  75.                                         {{ 'product_review.front.product_detail.name'|trans({ '%name%': ProductReview.reviewer_name }) }}
  76.                                     {% endif %}
  77.                                 </span>
  78.                                 <span class="review_date">
  79.                                     <!--投稿日-->
  80.                                     {{ ProductReview.create_date|date_day }}
  81.                                 </span>
  82.                             </p>
  83.                             <!--レビューコメント-->
  84.                             <p class="_des">{{ ProductReview.comment|nl2br }}</p>
  85.                         </li>
  86.                     {% endfor %}
  87.                 </ul>
  88.             {% else %}
  89.                 <p>{{ 'product_review.front.product_detail.no_review'|trans }}</p>
  90.             {% endif %}
  91.         </div>
  92.     </div>
  93. </div>
  94. <!-- ▲レビューエリア -->