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

Open in your IDE?
  1. {#
  2. おすすめ商品などの商品一覧を表示するカルーセル
  3. ex. 当店のイチオシ! ブレーカおすすめ商品
  4. @param string $label ブロックのタイトル
  5. @param string $href_label ブロックのリンクテキスト
  6. SCSS: /html/template/default/assets/scss/bluewood/twig/_category-list.scss
  7. #}
  8. {% set request_uri = app.request.server.get('REQUEST_URI') %}
  9. {% set category_ids = [5, 6, 9, 11, 12, 13, 14, 15, 16, 18, 19, 20, 21, 22, 24, 25, 26, 28, 29, 30, 32, 34, 35] %}
  10. {% set Categories = repository("Eccube\\Entity\\Category")
  11. .createQueryBuilder('c')
  12. .where('c.id IN (:category_ids)')
  13. .setParameter('category_ids', category_ids)
  14. .getQuery()
  15. .getResult() %}
  16. <section>
  17.     {% if label %}
  18.         <div class="heading_with_search_icon heading_with_search_icon--list-page">
  19.             <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
  20.                 <path d="M10.875 18.75C15.2242 18.75 18.75 15.2242 18.75 10.875C18.75 6.52576 15.2242 3 10.875 3C6.52576 3 3 6.52576 3 10.875C3 15.2242 6.52576 18.75 10.875 18.75Z" stroke="#CF0800" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
  21.                 <path d="M16.4424 16.4434L20.9986 20.9997" stroke="#CF0800" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
  22.             </svg>
  23.             <h2 class="heading_with_search_icon__text">{{ label }}</h2>
  24.         </div>
  25.     {% endif %}
  26.     <div class="grid-container">
  27.     {% for c in Categories %}
  28.     {% set path = asset('assets/img/category/category-img-' ~ c.id ~ '.jpg', "user_data") %}
  29.         <div class="grid-item">
  30.             <a href="{{ url('product_list') }}?category_id={{c.id}}" class="category-list-item">
  31.                 <img src="{{path}}" alt="{{ c.name }}" width="60" height="60" class="category-list-item__img">
  32.                 <div class="category-list-item__label">{{ c.name }}</div>
  33.             </a>
  34.         </div>
  35.     {% endfor %}
  36.     </div>
  37.     <div class="d-flex justify-content-center">
  38.         <button type="button" id="js-collapse" class="sercah-by-category">
  39.             <span>{{ href_label }}</span>
  40.             <span
  41.             class="sercah-by-category__icon"
  42.             >
  43.                 <svg  viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
  44.                     <path d="M6 3L11 8L6 13" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/
  45.                     >
  46.                 </svg>                    
  47.             </span>
  48.         </a>
  49.     </div>
  50. </section>
  51. {% block javascript %}
  52.     <script>
  53.         // カテゴリ一覧から探すを押した時に全てのカテゴリを表示する
  54.         $(document).ready(function() {
  55.             $('.grid-item').hide();
  56.             $('.grid-item:lt(12)').show();
  57.             $('#js-collapse').on('click', () => {
  58.                 $('.grid-item').show();
  59.                 $('#js-collapse').hide();
  60.             });
  61.         });
  62.     </script>
  63. {% endblock %}