app/template/yamaria/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. <style type="text/css">
  19.     #product_review_area {
  20.         border-top: 1px solid #E8E8E8;
  21.         padding-bottom: 0;
  22.         margin-bottom: 20px;
  23.     }
  24.     #product_review_area .ec-rectHeading {
  25.         cursor: pointer;
  26.         margin-top: 20px;
  27.         margin-bottom: 20px;
  28.     }
  29.     #product_review_area .ec-rectHeading.is_active i {
  30.         transform: rotate(180deg);
  31.     }
  32.     #product_review_area .review_list {
  33.         padding-left: 25px;
  34.     }
  35.     #product_review_area .review_list li {
  36.         margin-bottom: 16px;
  37.     }
  38.     #product_review_area .review_list .review_date {
  39.         font-weight: bold;
  40.     }
  41.     #product_review_area .recommend_average {
  42.         margin-left: 16px;
  43.         color: #DE5D50;
  44.     }
  45.     #product_review_area .review_list .recommend_level {
  46.         margin-left: 16px;
  47.         color: #DE5D50;
  48.     }
  49.     #product_review_area .review_list .recommend_name {
  50.         margin-left: 16px;
  51.     }
  52. </style>
  53. <script>
  54.     $(function() {
  55.         $('#product_review_area').appendTo($('.ec-layoutRole__main, .ec-layoutRole__mainWithColumn, .ec-layoutRole__mainBetweenColumn'));
  56.         $('#product_review_area .ec-rectHeading').on('click', function() {
  57.             $content = $('#reviewContent');
  58.             if ($content.css('display') == 'none') {
  59.                 $(this).addClass('is_active');
  60.                 $content.addClass('is_active');
  61.                 $content.slideDown(300);
  62.             } else {
  63.                 $(this).removeClass('is_active');
  64.                 $content.removeClass('is_active');
  65.                 $content.slideUp(300);
  66.             }
  67.             return false;
  68.         });
  69.     });
  70. </script>
  71. <!--▼レビューエリア-->
  72. <div id="product_review_area">
  73.     <div class="ec-role">
  74.         {% set positive_avg_star = ProductReviewAvg %}
  75.         {% set negative_avg_star = 5 - positive_avg_star %}
  76.         <div class="ec-rectHeading is_active">
  77.             <h4>{{ 'product_review.front.product_detail.title'|trans }}
  78.                 <!--平均の星の数-->
  79.                 <span class="recommend_average">{{ stars.stars(positive_avg_star, negative_avg_star) }}</span>
  80.                 <!--レビュー数-->
  81.                 <span>({{ ProductReviewCount }})</span>
  82.                 <span class="chevron pull-right">
  83.                     <i class="fas fa-angle-up fa-lg"></i>
  84.                 </span>
  85.             </h4>
  86.         </div>
  87.         <div id="reviewContent">
  88.             {% if ProductReviews %}
  89.                 <ul class="review_list">
  90.                     {% for ProductReview in ProductReviews %}
  91.                         <li>
  92.                             <p class="review_date">
  93.                                 <!--投稿日-->
  94.                                 {{ ProductReview.create_date|date_day }}
  95.                                 <!--投稿者-->
  96.                                 <span class="recommend_name">
  97.                                             {% if ProductReview.reviewer_url %}
  98.                                                 <a href="{{ ProductReview.reviewer_url }}" rel="ugc nofollow"
  99.                                                    target="_blank">{{ 'product_review.front.product_detail.name'|trans({ '%name%': ProductReview.reviewer_name }) }}</a>
  100.                                             {% else %}
  101.                                                 {{ 'product_review.front.product_detail.name'|trans({ '%name%': ProductReview.reviewer_name }) }}
  102.                                             {% endif %}
  103.                                         </span>
  104.                                 <!--星の数-->
  105.                                 {% set positive_star = ProductReview.recommend_level %}
  106.                                 {% set negative_star = 5 - positive_star %}
  107.                                 <span class="recommend_level">
  108.                                             {{ stars.stars(positive_star, negative_star) }}
  109.                                         </span>
  110.                             </p>
  111.                             <!--タイトル-->
  112.                             <strong>{{ ProductReview.title }}</strong>
  113.                             <!--レビューコメント-->
  114.                             <p>{{ ProductReview.comment|nl2br }}</p>
  115.                         </li>
  116.                     {% endfor %}
  117.                 </ul>
  118.             {% else %}
  119.                 <p>{{ 'product_review.front.product_detail.no_review'|trans }}</p>
  120.             {% endif %}
  121.         </div>
  122.         <div>
  123.             <a href="{{ url('product_review_index', { id: Product.id }) }}"
  124.                class="ec-inlineBtn--action">{{ 'product_review.front.product_detail.post_review'|trans }}</a>
  125.         </div>
  126.     </div>
  127. </div>
  128. <!-- ▲レビューエリア -->