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

Open in your IDE?
  1. {% set recommend_products = repository('Plugin\\Recommend42\\Entity\\RecommendProduct').getRecommendProduct %}
  2. {% block stylesheet %}
  3.     <style>
  4.         .slick-slider {
  5.             margin-bottom: 30px;
  6.         }
  7.         .slick-dots {
  8.             position: absolute;
  9.             bottom: -25px;
  10.             display: block;
  11.             width: 100%;
  12.             padding: 0;
  13.             list-style: none;
  14.             text-align: center;
  15.         }
  16.         .slick-dots li {
  17.             position: relative;
  18.             display: inline-block;
  19.             width: 20px;
  20.             height: 20px;
  21.             margin: 0 5px;
  22.             padding: 0;
  23.             cursor: pointer;
  24.         }
  25.         .slick-dots li button {
  26.             font-size: 0;
  27.             line-height: 0;
  28.             display: block;
  29.             width: 20px;
  30.             height: 20px;
  31.             padding: 5px;
  32.             cursor: pointer;
  33.             color: transparent;
  34.             border: 0;
  35.             outline: none;
  36.             background: transparent;
  37.         }
  38.         .slick-dots li button:hover,
  39.         .slick-dots li button:focus {
  40.             outline: none;
  41.         }
  42.         .slick-dots li button:hover:before,
  43.         .slick-dots li button:focus:before {
  44.             opacity: 1;
  45.         }
  46.         .slick-dots li button:before {
  47.             content: " ";
  48.             line-height: 20px;
  49.             position: absolute;
  50.             top: 0;
  51.             left: 0;
  52.             width: 12px;
  53.             height: 12px;
  54.             text-align: center;
  55.             opacity: .25;
  56.             background-color: black;
  57.             border-radius: 50%;
  58.         }
  59.         .slick-dots li.slick-active button:before {
  60.             opacity: .75;
  61.             background-color: black;
  62.         }
  63.         .slick-dots li button.thumbnail img {
  64.             width: 0;
  65.             height: 0;
  66.         }
  67.         .slick-prev, .slick-next {
  68.             font-size: 0;
  69.             line-height: 0;
  70.             position: absolute;
  71.             top: 50%;
  72.             display: block;
  73.             width: 60px;
  74.             height: 60px;
  75.             padding: 0;
  76.             -webkit-transform: translate(0, -50%);
  77.             -ms-transform: translate(0, -50%);
  78.             transform: translate(0, -50%);
  79.             cursor: pointer;
  80.             color: transparent;
  81.             border: none;
  82.             outline: none;
  83.             background: transparent;
  84.         }
  85.         .slick-prev {
  86.             left: 0;
  87.             z-index: 1;
  88.             height: 30px;
  89.         }
  90.         .slick-next {
  91.             right: 0;
  92.             z-index: 1;
  93.             height: 30px;
  94.         }
  95.         .slick-prev:before, .slick-next:before {
  96.             font-family: 'slick';
  97.             font-size: 40px;
  98.             line-height: 1;
  99.             opacity: 1;
  100.             color: white;
  101.             -webkit-font-smoothing: antialiased;
  102.             -moz-osx-font-smoothing: grayscale;
  103.         }
  104.         .slick-prev:before {
  105.             content: "";
  106.             opacity: 0;
  107.             pointer-events: none;
  108.             transition: opacity 0.3s ease;
  109.         }
  110.         .slick-next:before {
  111.             content: "";
  112.             opacity: 0;
  113.             pointer-events: none;
  114.             transition: opacity 0.3s ease;
  115.         }
  116.         {# .slick-prev:hover,
  117.         .slick-prev:focus,
  118.         .slick-next:hover,
  119.         .slick-next:focus {
  120.             color: transparent;
  121.             outline: none;
  122.             background: transparent;
  123.         } #}
  124.         {# .slick-prev:hover:before,
  125.         .slick-prev:focus:before,
  126.         .slick-next:hover:before,
  127.         .slick-next:focus:before {
  128.             opacity: 1;
  129.         } #}
  130.         {# .slick-prev.slick-disabled:before,
  131.         .slick-next.slick-disabled:before {
  132.             opacity: .25;
  133.         } #}
  134.         .slick-track{
  135.             position: relative;
  136.             top: 0;
  137.             left: 0;
  138.             display: flex;
  139.             margin-left: auto;
  140.             margin-right: auto;
  141.         }
  142.         .product_name{
  143.             font-size: 15px;
  144.             height: 40px;
  145.             overflow: hidden;
  146.             display: -webkit-box;
  147.             text-overflow: ellipsis;
  148.             -webkit-box-orient: vertical;
  149.             -webkit-line-clamp: 2;
  150.             color: #1F9FCB;
  151.             margin-top: 8px;
  152.         }
  153.         .standardText {
  154.             color: #000000;
  155.             font-size: 12px;
  156.             padding-top: 8px;
  157.             padding-bottom: 8px;
  158.         }
  159.         .item_price {
  160.             color: black;
  161.             font-size: 18px;
  162.             font-weight: bold;
  163.         }
  164.     {# PC用スタイル #}
  165.     @media screen and (min-width: 1025px) {
  166.         /* .ec-sliderRole にホバーしたときだけ表示 */
  167.         .ec-sliderRole:hover .slick-prev:before,
  168.         .ec-sliderRole:hover .slick-next:before {
  169.             opacity: 1;
  170.             pointer-events: auto;
  171.         }
  172.         .slick-next:before {
  173.             content: "";
  174.             display: block;
  175.             width: 54px;
  176.             height: 54px;
  177.             background-image: url(/html/user_data/assets/img/common/btn_carousel_r_2.png);
  178.             background-size: contain;
  179.             margin-left: 40px;
  180.         }
  181.        .slick-prev:before {
  182.             content: "";
  183.             display: block;
  184.             width: 54px;
  185.             height: 54px;
  186.             background-image: url(/html/user_data/assets/img/common/btn_carousel_l_2.png);
  187.             background-size: contain;
  188.             margin-left: -40px;
  189.         }
  190.     }
  191.     {# スマホ&タブレット用スタイル #}
  192.     @media screen and (max-width: 1024px) {
  193.     }
  194.     </style>
  195. {% endblock %}
  196. {% block javascript %}
  197.     <script>
  198.         $(function() {
  199.             let width = $(window).width();
  200.             var photo_count = 2;
  201.             if (width <= 768) {
  202.             } else if (width <= 1024) {
  203.                 // タブレット
  204.                 photo_count = 4;
  205.             } else {
  206.                 // PC
  207.                 photo_count = 4;
  208.             }
  209.             $('.main_visual_2').slick({
  210.                 dots: false,
  211.                 autoplay: false,
  212.                 centerMode: true,
  213.                 centerPadding: '10%',
  214.                 arrows: true,
  215.                 infinite: true,
  216.                 slidesToShow: photo_count,
  217.                 swipeToSlide: true,
  218.                 touchMove: true,
  219.                 touchThreshold: 10,
  220.             });
  221.         });
  222.     </script>
  223. {% endblock javascript %}
  224. {% block main %}
  225.     <div class="block_content" style="max-width: 1150px; margin: auto; padding-left: 10px; padding-right: 10px; margin-bottom: 0px;">
  226.         <h2 style="font-size: 18px; margin-bottom: 16px;">おすすめ商品</h2>
  227.     </div>
  228.     <div class="ec-sliderRole" style="margin-bottom: 0px; padding: 0px 10px;">
  229.         <div class="main_visual_2" style="margin-bottom: 0px;">
  230.             {% for RecommendProduct in recommend_products %}
  231.             <div class="item slick-slide" style="padding: 6px;">
  232.                 <a href="{{ url('product_detail', {'id': RecommendProduct.Product.id}) }}">
  233.                     <img src="{{ asset(RecommendProduct.Product.mainFileName|no_image_product, "save_image") }}" style="width: 320px; height: 136px; object-fit: cover; border-radius: 4px;">
  234.                     <dl>
  235.                         {# 商品名 #}
  236.                         <p class="product_name">{{ RecommendProduct.Product.name }}</p>
  237.                         {# 規格 #}
  238.                         <p class="standardText">{{ RecommendProduct.Product.getStandardText }}</p>
  239.                         <dd class="item_price">
  240.                             {{ RecommendProduct.Product.getPrice02IncTaxMin|number_format }}円
  241.                         </dd>
  242.                     </dl>
  243.                 </a>
  244.             </div>
  245.             {% endfor %}
  246.         </div>
  247.     </div>
  248. {% endblock %}