app/template/HF4002/Block/category_nav_sp.twig line 1

Open in your IDE?
  1. {#
  2. This file is part of EC-CUBE
  3. Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  4. http://www.ec-cube.co.jp/
  5. For the full copyright and license information, please view the LICENSE
  6. file that was distributed with this source code.
  7. #}
  8. {% set Categories = repository('Eccube\\Entity\\Category').getList() %}
  9. {% set start_date = '2021-09-06'|date('Y-m-d') %}
  10. {% set end_date = '2021-09-27'|date('Y-m-d') %}
  11. {% set sale_campaign_id = 174 %}
  12. {% if start_date <= date()|date('Y-m-d') and date()|date('Y-m-d') <= end_date %}
  13.     {% set campaign_valid = true %}
  14. {% else %}
  15.     {% set campaign_valid = false %}
  16. {% endif %}
  17. {% set Categories = repository('Eccube\\Entity\\Category').getList() %}
  18. {% macro tree(Category, level) %}
  19.     {% from _self import tree %}
  20.     {% if level == 0 %}
  21.     <a href="{{ url('product_list') }}?category_id={{ Category.id }}">
  22.         {{ Category.name }}
  23.     </a>
  24.     {% else  %}
  25.     <a href="{{ url('product_list') }}?category_id={{ Category.id }}" style="color:#2a83a2!important">
  26.         {{ Category.name }}
  27.     </a>
  28.     {% endif %}
  29.     {% if Category.children|length > 0 %}
  30.         <ul>
  31.             {% for ChildCategory in Category.children %}
  32.                 <li>
  33.                     {{ tree(ChildCategory, 1) }}
  34.                 </li>
  35.             {% endfor %}
  36.         </ul>
  37.     {% endif %}
  38. {% endmacro %}
  39. {# @see https://github.com/bolt/bolt/pull/2388 #}
  40. {% from _self import tree %}
  41. <style>
  42.     #campaign_sp {
  43.         background-color: red !important;
  44.         border: 3px double #fff;
  45.     }
  46.     #campaign_sp a {
  47.         color: white!important;
  48.     }
  49. </style>
  50. <div class="ec-headerCategoryArea">
  51.     <div class="ec-headerCategoryArea__heading">
  52.         <p><a href="{{ url('product_list') }}">{{ '全商品一覧'|trans }}</a></p>
  53.     </div>
  54.     <div class="ec-itemNav">
  55.         <ul class="ec-itemNav__nav">
  56.             {% if campaign_valid %}
  57.                 <li id="campaign_sp">
  58.                     <a href="{{ url('product_list') }}?category_id={{ sale_campaign_id }}">セール</a>
  59.                 </li>
  60.             {% endif %}
  61.             {% for Category in Categories %}
  62.                 {% if Category.id not in [10,19,sale_campaign_id] %}
  63.                 <li>
  64.                     {{ tree(Category, 0) }}
  65.                 </li>
  66.                 {% endif %}
  67.             {% endfor %}
  68.         </ul>
  69.     </div>
  70. </div>