app/Plugin/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.     #product_review_area .review_no_comment{
  53.         text-align: center;
  54.     }
  55.     #product_review_area .review_action_post{
  56.         text-align: center;
  57.         margin: 1em;
  58.     }
  59. </style>
  60. <script>
  61.     $(function() {
  62.         $('#product_review_area').appendTo($('.ec-layoutRole__main, .ec-layoutRole__mainWithColumn, .ec-layoutRole__mainBetweenColumn'));
  63.         $('#product_review_area .ec-rectHeading').on('click', function() {
  64.             $content = $('#reviewContent');
  65.             if ($content.css('display') == 'none') {
  66.                 $(this).addClass('is_active');
  67.                 $content.addClass('is_active');
  68.                 $content.slideDown(300);
  69.             } else {
  70.                 $(this).removeClass('is_active');
  71.                 $content.removeClass('is_active');
  72.                 $content.slideUp(300);
  73.             }
  74.             return false;
  75.         });
  76.     });
  77. </script>
  78. <!--▼レビューエリア-->
  79. <div id="product_review_area">
  80.     <div class="ec-role">
  81.         {% set positive_avg_star = ProductReviewAvg %}
  82.         {% set negative_avg_star = 5 - positive_avg_star %}
  83.         <div class="ec-rectHeading is_active">
  84.             <h4>{{ 'product_review.front.product_detail.title'|trans }}
  85.                 <!--平均の星の数-->
  86.                 <span class="recommend_average">{{ stars.stars(positive_avg_star, negative_avg_star) }}</span>
  87.                 <!--レビュー数-->
  88.                 <span>({{ ProductReviewCount }})</span>
  89.                 <span class="chevron pull-right">
  90.                     <i class="fas fa-angle-up fa-lg"></i>
  91.                 </span>
  92.             </h4>
  93.         </div>
  94.         <div id="reviewContent">
  95.             {% if ProductReviews %}
  96.                 <ul class="review_list">
  97.                     {% for ProductReview in ProductReviews %}
  98.                         <li>
  99.                             <p class="review_date">
  100.                                 <!--投稿日-->
  101.                                 {{ ProductReview.create_date|date_day }}
  102.                                 <!--投稿者-->
  103.                                 <span class="recommend_name">
  104.                                             {% if ProductReview.reviewer_url %}
  105.                                                 <a href="{{ ProductReview.reviewer_url }}" rel="ugc nofollow"
  106.                                                    target="_blank">{{ 'product_review.front.product_detail.name'|trans({ '%name%': ProductReview.reviewer_name }) }}</a>
  107.                                             {% else %}
  108.                                                 {{ 'product_review.front.product_detail.name'|trans({ '%name%': ProductReview.reviewer_name }) }}
  109.                                             {% endif %}
  110.                                         </span>
  111.                                 <!--星の数-->
  112.                                 {% set positive_star = ProductReview.recommend_level %}
  113.                                 {% set negative_star = 5 - positive_star %}
  114.                                 <span class="recommend_level">
  115.                                             {{ stars.stars(positive_star, negative_star) }}
  116.                                         </span>
  117.                             </p>
  118.                             <!--タイトル-->
  119.                             <strong>{{ ProductReview.title }}</strong>
  120.                             <!--レビューコメント-->
  121.                             <p>{{ ProductReview.comment|nl2br }}</p>
  122.                         </li>
  123.                     {% endfor %}
  124.                 </ul>
  125.             {% else %}
  126.                 <p class="review_no_comment">{{ 'product_review.front.product_detail.no_review'|trans }}</p>
  127.             {% endif %}
  128.         </div>
  129.         <div class="review_action_post">
  130.             <a href="{{ url('product_review_index', { id: Product.id }) }}"
  131.                class="ec-inlineBtn--action">{{ 'product_review.front.product_detail.post_review'|trans }}</a>
  132.         </div>
  133.     </div>
  134. </div>
  135. <!-- ▲レビューエリア -->