app/template/default/Block/recently_viewed_products.twig line 1

Open in your IDE?
  1. {% block stylesheet %}
  2.     <style>
  3.     {# タイトル #}
  4.     .ec-secHeading span.ec-secHeading__ja {
  5.         color: #000;
  6.         font-size: 18px;
  7.         font-style: normal;
  8.         font-weight: 700;
  9.         line-height: 24px;
  10.         letter-spacing: normal;
  11.         vertical-align: 0px;
  12.     }
  13.     {# 商品画像 #}
  14.     .ec-historyRole__listImage {
  15.         margin-bottom: 8px;
  16.     }
  17.     .ec-historyRole__listImage img {
  18.         width: 96px;
  19.         height: 96px;
  20.         object-fit: cover;
  21.         border-radius: 96px; 
  22.     }
  23.     .ec-historyRole__listItemTitle {
  24.         color: #000;
  25.         text-align: center;
  26.         font-size: 14px;
  27.         font-style: normal;
  28.         font-weight: 600;
  29.         line-height: 18px;
  30.         width: 96px;
  31.         display: -webkit-box;              /* flexboxの一種(省略に必要) */
  32.         -webkit-line-clamp: 2;             /* 最大行数 */
  33.         -webkit-box-orient: vertical;      /* 縦方向に行を積む */
  34.         overflow: hidden;                  /* 溢れた部分を非表示 */
  35.         text-overflow: ellipsis;           /* … を表示 */
  36.         word-break: break-word;            /* 長い単語も折り返す */
  37.     }
  38.     
  39.     .recently_product .item {
  40.         margin-right: 10px;
  41.     }
  42.     /* モバイル(幅767px以下) */
  43.     @media screen and (max-width: 767px) {
  44.         .ec-historyRole__listImage img {
  45.             width: 80px;
  46.             height: 80px;
  47.             object-fit: cover;
  48.             border-radius: 80px;
  49.         }
  50.         .ec-historyRole__listItemTitle {
  51.             font-size: 12px;
  52.             font-weight: 600;
  53.             line-height: 18px;
  54.             width: 80px;
  55.         }
  56.         .ec-role {
  57.             padding-left: 0px;
  58.             padding-right: 0px;
  59.         }
  60.         
  61.         .recently_product {
  62.             margin-left: 16px;
  63.         }
  64.         .ec-secHeading {
  65.             margin-left: 16px;
  66.         }
  67.         
  68.         .recently_product .item {
  69.             margin-right: 0px;
  70.         }
  71.     }
  72.     </style>
  73. {% endblock %}
  74. {% block javascript %}
  75.     <script>
  76.         
  77.         $(function() {
  78.             $('.recently_product').slick({
  79.                 dots: false,
  80.                 autoplay: true,
  81.                 autoplaySpeed: 1000,
  82.                 centerMode: false,   // 中央寄せしない
  83.                 variableWidth: true, // スライド幅に合わせて並べる(左寄せにしやすい)
  84.                 centerPadding: '1%',
  85.                 arrows: false,
  86.                 infinite: false,
  87.                 slidesToShow: 9,
  88.                 swipeToSlide: true
  89.             });
  90.         });
  91.     </script>
  92. {% endblock javascript %}
  93. {% if RecentlyViewedProducts|length > 0 %}
  94. <div class="ec-role" style="margin-bottom: 24px;">
  95.     <div class="ec-historyRole">
  96.         <div class="ec-historyRole__heading">
  97.             <div class="ec-secHeading">
  98.                 <span class="ec-secHeading__ja">最近閲覧した商品</span>
  99.             </div>
  100.         </div>
  101.         <div class="recently_product" style="">
  102.             {% for Product in RecentlyViewedProducts %}
  103.                 <div class="item slick-slide" style="">
  104.                     <a href="{{ url('product_detail', {id: Product.id}) }}">
  105.                         <div class="ec-historyRole__listImage">
  106.                             <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}" style="background: url('{{ asset(Product.main_list_image|no_image_product, 'save_image') }}') lightgray 50% / cover no-repeat;" alt="{{ Product.name }}" loading="lazy">
  107.                         </div>
  108.                         <p class="ec-historyRole__listItemTitle">{{ Product.name }}</p>
  109.                     </a>
  110.                 </div>
  111.             {% endfor %}
  112.         </div>
  113.     </div>
  114. </div>
  115. {% endif %}