app/template/default/category_detail.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. {% extends 'default_frame.twig' %}
  9. {% set body_class = 'category_detail' %}
  10. {% set childCategories = repository('Eccube\\Entity\\Category').find(category.id).getDescendants() %}
  11. {% block javascript %}
  12. <script type="text/javascript">
  13. $(function(){
  14.   $('.mod_movie-btn-favorite').on('click', function(){
  15.     let loginStatus = {{ is_granted('ROLE_USER') ? 'true' : 'false' }};
  16.     if(loginStatus){
  17.       let pid = $(this).data('pid');
  18.       let tmpbtn = $(this);
  19.       // tmpbtn.children("input").prop('disabled', true);
  20.       tmpbtn.children("input").attr('disabled', true);
  21.       if(tmpbtn.hasClass('favorite__del')){
  22.         $.ajax({
  23.           url: "{{ url('homepage') }}refine_delete_favorite",
  24.           type: 'GET',
  25.           dataType: 'text',
  26.           data: {id: pid}
  27.         })
  28.         .then(
  29.           function (data) {
  30.               tmpbtn.removeClass('favorite__del');
  31.               tmpbtn.addClass('favorite__add');
  32.           },
  33.           function () {
  34.               alert("処理に失敗しました。お手数ですが再度実行してください");
  35.         });
  36.       } else {
  37.           $.ajax({
  38.             url: "{{ url('homepage') }}products/add_favorite/"+pid,
  39.             type: 'POST',
  40.           })
  41.           .then(
  42.             function (data) {
  43.                 tmpbtn.removeClass('favorite__add');
  44.                 tmpbtn.addClass('favorite__del');
  45.             },
  46.             function () {
  47.               alert("処理に失敗しました。お手数ですが再度実行してください");
  48.           });
  49.       }
  50.       // tmpbtn.children("input").prop('disabled', false);
  51.       tmpbtn.children("input").attr('disabled', false);
  52.     } else {
  53.        location.href= "{{ url('mypage_delivery') }}";
  54.     }
  55.   });
  56.   // 表示件数を変更
  57.   $('.disp-number').change(function() {
  58.       var dispNumber = $(this).val();
  59.       $('#disp_number').val(dispNumber);
  60.       $('#pageno').val(1);
  61.       $("#form1").submit();
  62.   });
  63.   // 並び順を変更
  64.   $('.order-by').change(function() {
  65.       var orderBy = $(this).val();
  66.       $('#orderby').val(orderBy);
  67.       $('#pageno').val(1);
  68.       $("#form1").submit();
  69.   });
  70. });
  71. </script>
  72. {% endblock %}
  73. {% block stylesheet %}
  74. <style>
  75.   .ec-searchnavRole {
  76.     margin-top: 30px;
  77.   }
  78. </style>
  79. {% endblock %}
  80. {% block main %}
  81. <div class="content__inner">
  82.   <div class="mod_breadcrumb">
  83.     <ul>
  84.       <li>
  85.         <a href="{{ url('homepage') }}">{{ 'ホーム'|trans }}</a>
  86.       </li>
  87.       <li>
  88.         <a href="{{ url('category_list') }}">{{ 'カテゴリ一覧'|trans }}</a>
  89.       </li>
  90.       {# 親カテゴリの設定 #}
  91.       {% set parentCategory = category.getParent %}
  92.       {% if parentCategory is not empty %}
  93.         <li><a href="{{ url('categories/{category_id}', { 'category_id': parentCategory.id }) }}">{{ parentCategory.name|trans }}</a></li>
  94.       {% endif %}
  95.       <li>
  96.         <span>{{ category.name|trans }}</span>
  97.       </li>
  98.     </ul>
  99.   </div>
  100.   <form name="form1" id="form1" method="get" action="?">
  101.     {% for item in search_form %}
  102.       <input type="hidden" id="{{ item.vars.id }}"
  103.         name="{{ item.vars.full_name }}"
  104.         {% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
  105.     {% endfor %}
  106.   </form>
  107.   <div class="page__content">
  108.     <h1>{{ category.name|trans }}</h1>
  109.     <div class="page__inner">
  110.       <div class="ec-searchnavRole" style="padding: 0;margin-top:0;">
  111.         <div class="ec-searchnavRole__infos" style="border: none;padding-top:0;">
  112.           <div class="ec-searchnavRole__counter">
  113.             {% if pagination.totalItemCount > 0 %}
  114.             {{ '<span class="ec-font-bold">%count%件</span><span>の動画が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
  115.             {% else %}
  116.             <span>{{ 'お探しの動画は見つかりませんでした'|trans }}</span>
  117.             {% endif %}
  118.           </div>
  119.           {% if pagination.totalItemCount > 0 %}
  120.           <div class="ec-searchnavRole__actions">
  121.             <div class="ec-select">
  122.               {{ form_widget(disp_number_form, {'id': '', 'attr': {'class': 'disp-number'}}) }}
  123.               {{ form_widget(order_by_form, {'id': '', 'attr': {'class': 'order-by'}}) }}
  124.             </div>
  125.           </div>
  126.           {% endif %}
  127.         </div>
  128.       </div>
  129.       {% if childCategories is defined and childCategories|length > 0 %}
  130.       {# 表示用計算 #}
  131.       {% set cntTotalPublished = 0 %}
  132.       {% for childCategory in childCategories %}
  133.         {# サブスクリプション, 新入荷, 講師は除く #}
  134.         {% if childCategory.id != 7 and childCategory.id != 2 and childCategory.id != 64 %}
  135.           {# 公開のみカウント #}
  136.           {% if childCategory.ProductCategories is not empty %}
  137.             {% for ProductCategory in childCategory.ProductCategories %}
  138.               {% set cntTotalPublished = cntTotalPublished + (ProductCategory.Product is not empty and ProductCategory.Product.Status.id == 1 ? 1 : 0) %}
  139.             {% endfor %}
  140.           {% endif %}
  141.         {% endif %}
  142.       {% endfor %}
  143.       {# カテゴリに紐付いた記事があれば表示 #}
  144.       {% if (cntTotalPublished > 0) %}
  145.       <div class="mod_inpage-link">
  146.         <h5>{{ 'さらに絞り込んで表示する'|trans }}</h5>
  147.         <ul>
  148.           {% for childCategory in childCategories %}
  149.               {# サブスクリプション, 新入荷, 講師は除く #}
  150.               {% if childCategory.id != 7 and childCategory.id != 2 and childCategory.id != 64 %}
  151.                 {% set cntPublished = 0 %}
  152.                 {# 公開のみカウント #}
  153.                 {% if childCategory.ProductCategories is not empty %}
  154.                   {% for ProductCategory in childCategory.ProductCategories %}
  155.                     {% set cntPublished = cntPublished + (ProductCategory.Product is not empty and ProductCategory.Product.Status.id == 1 ? 1 : 0) %}
  156.                   {% endfor %}
  157.                 {% endif %}
  158.                 {% if (cntPublished > 0) %}
  159.           <li>
  160.             <a href="{{ url('categories/{category_id}', { 'category_id': childCategory.id }) }}">{{ childCategory.name|trans }}</a>
  161.           </li>
  162.                 {% endif %}
  163.               {% endif %}
  164.           {% endfor %}
  165.         </ul>
  166.       </div>
  167.       {% endif %}
  168.       {% endif %}
  169.       {% if pagination is defined and pagination.totalItemCount > 0 %}
  170.       <ul class="mod_movie-list">
  171.         {% for item in pagination %}
  172.           {% set productClass = item.ProductClasses.get(0) %}
  173.           {% set videoContent = productClass.ProductClassContent.get(0) %}
  174.           {# 通常は動画閲覧画面、コンテンツがない場合は商品詳細へ #}
  175.           {% if videoContent is not empty %}
  176.             {% set anker = url('video/{product_id}/content/{content_id}', {'product_id': item.id, 'content_id': videoContent.Content.id}) %}
  177.           {% else %}
  178.             {% set anker = url('product_detail', {id: item.id}) %}
  179.           {% endif %}
  180.           {% set isFavorite = customer is not empty and repository('Eccube\\Entity\\CustomerFavoriteProduct').isFavorite(customer, item) %}
  181.           <li class="mod_movie-item">
  182.             <div class="mod_movie-item-inner">
  183.               <div class="mod_movie-img-wrapper">
  184.                 <a href="{{ anker }}">
  185.                   {% if item.ProductImage is defined and item.ProductImage is not empty %}
  186.                     <img src="{{ asset(item.ProductImage.get(0), 'save_image') }}" alt="Product.name" />
  187.                   {% else %}
  188.                     <img src="{{ asset(''|no_image_product, 'save_image') }}" alt="" />
  189.                   {% endif %}
  190.                 </a>
  191.               </div>
  192.               <div class="mod_movie-text-wrapper">
  193.                 <a href="{{ anker }}" class="mod_movie-title">{{ item.name|trans }}</a>
  194.                 {% set searchWords = item.search_word|split(',') %}
  195.                 <ul class="mod_movie-keyword-list">
  196.                   {% for word in searchWords %}
  197.                     {% if word is not empty %}
  198.                     <li class="mod_movie-keyword-item">
  199.                       <span>{{ word|trans }}</span>
  200.                     </li>
  201.                     {% endif %}
  202.                   {% endfor %}
  203.                 </ul>
  204.                 <div class="mod_movie-btn-wrapper">
  205.                   <div class="mod_movie-btn-favorite {{ (isFavorite == 1) ? 'favorite__del': 'favorite__add' }}" data-pid="{{ item.id }}">
  206.                   {# 一旦全部見たい授業とする #}
  207.                     {# {% if isFavorite and false %}
  208.                     <form action="{{ url('refine_delete_favorite', {id:item.id}) }}" method="post">
  209.                       <input type="submit" value="{{ '見たい授業'|trans }}" />
  210.                     </form>
  211.                     {% else %}
  212.                     <form action="{{ url('product_add_favorite', {id:item.id}) }}" method="post">
  213.                       <input type="submit" value="{{ '見たい授業'|trans }}" />
  214.                     </form>
  215.                     {% endif %} #}
  216.                     {# {% if isFavorite == 1 %} #}
  217.                         <input type="button" class="favorite-btn" value="{{ '見たい授業'|trans }}" />
  218.                     {# {% else %}
  219.                         <input type="button" class="favorite-btn" value="{{ '見たい授業'|trans }}" />
  220.                     {% endif %} #}
  221.                   </div>
  222.                   <a href="{{ anker }}" class="mod_movie-btn-watch">
  223.                     <span>{{ '見る'|trans }}</span>
  224.                   </a>
  225.                 </div>
  226.               </div>
  227.             </div>
  228.           </li>
  229.         {% endfor %}
  230.       </ul>
  231.       {% endif %}
  232.     </div>
  233.     {% include "category_pager.twig" with {'pages': pagination.paginationData} %}
  234.     <div class="page__inner">
  235.       <h2 class="mod_movie-h2">
  236.         {{ 'カテゴリ一覧'|trans }}
  237.       </h2>
  238.       <div class="mod_movie-btn-more">
  239.         <a href="{{ url('category_list') }}">{{ 'カテゴリ一覧に戻る'|trans }}</a>
  240.       </div>
  241.     </div>
  242.   </div>
  243. </div>
  244. {% endblock %}