app/template/HF4002/Block/category_nav_pc.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_category_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. <style>
  18.     @media only screen and (min-width: 769px){
  19.         ul.ec-itemNav__nav {
  20.             display: flex!important;
  21.             justify-content: space-between!important;
  22.             padding: 0px;
  23.         }
  24.         ul.ec-itemNav__nav li a{
  25.             padding: 12px!important;
  26.             margin-left: 0px!important;
  27.             height: auto;
  28.         }
  29.         .item_subcategory ul{
  30.             margin-top: 0px!important;
  31.             margin-left: -5px!important;
  32.         }
  33.         .item_subcategory ul li a{
  34.             height: 55px!important;
  35.             padding: 16px!important;
  36.         }
  37.         .ec-itemNav {
  38.             margin-bottom: 15px!important;
  39.         }
  40.     }
  41.     #campaign {
  42.         background-color: red;
  43.         
  44.     }
  45.     #campaign a {
  46.         border: 3px double #fff;
  47.         margin: 2px!important;
  48.         padding: 8px!important;
  49.         color: white!important;
  50.     }
  51.     }
  52. </style>
  53. {% macro tree(Category) %}
  54.     {% from _self import tree %}
  55.     <a href="{{ url('product_list') }}?category_id={{ Category.id }}">
  56.         {{ Category.name }}
  57.     </a>
  58.     {% if Category.children|length > 0 %}
  59.         <ul>
  60.       
  61.             {% for ChildCategory in Category.children %}
  62.                 <li>
  63.                     {{ tree(ChildCategory) }}
  64.                 </li>
  65.             {% endfor %}
  66.         </ul>
  67.     {% endif %}
  68. {% endmacro %}
  69. {# @see https://github.com/bolt/bolt/pull/2388 #}
  70. {% from _self import tree %}
  71. <div class="ec-categoryNaviRole">
  72.     <div class="ec-itemNav">
  73.         <ul class="ec-itemNav__nav">
  74.                 <li>
  75.                     <a href="{{ url('product_list') }}">全商品</a>
  76.                 </li>
  77.                 {% if campaign_valid %}
  78.                     <li class="item_subcategory" id="campaign">
  79.                         <a href="{{ url('product_list') }}?category_id={{ sale_category_id }}">セール</a>
  80.                     </li>
  81.                 {% endif %}
  82.             {% for Category in Categories %}
  83.                 {% if Category.id not in [10,19,sale_category_id] %}
  84.                 <li class="item_subcategory">
  85.                     {{ tree(Category) }}
  86.                 </li>
  87.                 {% endif %}
  88.             {% endfor %}
  89.         </ul>
  90.     </div>
  91. </div>