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

Open in your IDE?
  1. {% set Categories = repository('Eccube\\Entity\\Category').getList() %}
  2. {% block javascript %}
  3. <script>
  4. $(function() {
  5.     $('#type').change(function() {
  6.         var r = $('option:selected').val();
  7.         if(r == 1){
  8.             $('.search-poke').hide('fast');
  9.             $('.search-weis').show('fast');
  10.         }else if(r == 2){
  11.             $('.search-poke').show('fast');
  12.             $('.search-weis').hide('fast');
  13.         }else{
  14.             $('.search-weis').hide('fast');
  15.             $('.search-poke').hide('fast');
  16.         }
  17.     
  18.     })
  19.     //onload時にtypeの値を取得して表示
  20.     var r = $('#type option:selected').val();
  21.     if(r == 1){
  22.         $('.search-poke').hide();
  23.         $('.search-weis').show();
  24.     }else if(r == 2){
  25.         $('.search-poke').show();
  26.         $('.search-weis').hide();
  27.     }else{
  28.         $('.search-weis').hide();
  29.         $('.search-poke').hide();
  30.     }
  31. });
  32. </script>    
  33. {% endblock %}
  34. {% set catid = app.request.query.get('category_id') %}
  35. {% set name=app.request.query.get('name') %}
  36. {% set type=app.request.query.get('type') %}
  37. {% set category_id1=app.request.query.get('category_id1') %}
  38. {% set category_id2=app.request.query.get('category_id2') %}
  39. {% set category_id3=app.request.query.get('category_id3') %}
  40. {% set category_id4=app.request.query.get('category_id4') %}
  41. {% set category_id5=app.request.query.get('category_id5') %}
  42. {% set tag_id=app.request.query.get('tag_id') %}
  43. {% if catid ==  217 or catid ==  218 or catid ==  219  %}
  44.     <div class="wback searchbox">
  45.         <h2 class="maru">商品検索</h2>
  46.         <form method="get" action="/products/list">
  47.             <input type="hidden" name="category_id" id="category_id" value="217">
  48.             <input type="search" name="name" maxlength="50" class="search-name" placeholder="キーワードを入力" value="{{ name }}"><Br>
  49.             {# dump(Category_p) #}
  50.             <p>検索するカード</p>
  51.             <select name="type" id="type">
  52.                 {# type一致でselectedする #}
  53.                 <option value="0" {% if type == 0 %}selected{% endif %}>選択して下さい</option>
  54.                 <option value="1" {% if type == 1 %}selected{% endif %}>ヴァイスシュヴァルツ</option>
  55.                 <option value="2" {% if type == 2 %}selected{% endif %}>ポケモン</option>
  56.             </select>
  57.             
  58.             <div class="search-weis">
  59.             <p>タイトル</p>
  60.             <select name="category_id2">
  61.                 {# category_id2一致でselected 1はヴァイスシュヴァルツから検索 #}
  62.                 <option value="">ヴァイスシュヴァルツから検索</option>
  63.                 {% for Category in Categories %}
  64.                     {% if Category == "買い取り" %}
  65.                         {% for ChildCategory in Category.children %}
  66.                             {% if ChildCategory == "ヴァイスシュヴァルツ" %}
  67.                                 {% for MagoCategory in ChildCategory.children %}
  68.                                     {% if MagoCategory == "シュヴァルツサイド" or MagoCategory == "ヴァイスサイド"%}
  69.                                         {% for HimagoCategory in MagoCategory.children %}
  70.                                             <option value="{{ HimagoCategory.id }}" {% if category_id2 == HimagoCategory.id %}selected
  71.                                             {% endif %}>{{ HimagoCategory }}</option>
  72.                                         {% endfor %}
  73.                                     {% endif %}
  74.                                 {% endfor %}
  75.                             {% endif %}
  76.                         {% endfor %}
  77.                     {% endif %}
  78.                 {% endfor %}
  79.             </select><br>
  80.             
  81.             <p>レアリティ</p>
  82.             <select name="category_id3">
  83.                 {# category_id3一致でselected 0はレアリティを選択 #}
  84.                 <option value="">レアリティを選択</option>
  85.                 {% for Category in Categories %}
  86.                     {% if Category == "買い取り" %}
  87.                         {% for ChildCategory in Category.children %}
  88.                             {% if ChildCategory == "ヴァイスシュヴァルツ" %}
  89.                                 {% for MagoCategory in ChildCategory.children %}
  90.                                     {% if MagoCategory == "レアリティ"%}
  91.                                         {% for HimagoCategory in MagoCategory.children %}
  92.                                             <option value="{{ HimagoCategory.id }}" {% if category_id5 == HimagoCategory.id %}selected
  93.                                             {% endif %}>{{ HimagoCategory }}</option>
  94.                                         {% endfor %}
  95.                                     {% endif %}
  96.                                 {% endfor %}
  97.                             {% endif %}
  98.                         {% endfor %}
  99.                     {% endif %}
  100.                 {% endfor %}
  101.             </select><br>
  102.             </div>
  103.             <div class="search-poke">
  104.             <p>タイトル</p>
  105.             <select name="category_id4">
  106.                 {# category_id4一致でselected 0はポケモンから選択 #}
  107.                 <option value="">ポケモンから選択</option>
  108.                 {% for Category in Categories %}
  109.                     {% if Category == "買い取り" %}
  110.                         {% for ChildCategory in Category.children %}
  111.                             {% if ChildCategory == "ポケモン" %}
  112.                                 {% for MagoCategory in ChildCategory.children %}
  113.                                     {% if MagoCategory != "レアリティ" %}
  114.                                         <option value="{{ MagoCategory.id }}" {% if category_id4 == MagoCategory.id %}selected
  115.                                         {% endif %}>{{ MagoCategory }}</option>
  116.                                     {% endif %}
  117.                                 {% endfor %}
  118.                             {% endif %}
  119.                         {% endfor %}
  120.                     {% endif %}
  121.                 {% endfor %}
  122.             </select><br>
  123.             
  124.             <p>レアリティ</p>
  125.             <select name="category_id5">
  126.                 {# category_id5一致でselected 0はレアリティを選択 #}
  127.                 <option value="">レアリティを選択</option>
  128.                 {% for Category in Categories %}
  129.                     {% if Category == "買い取り" %}
  130.                         {% for ChildCategory in Category.children %}
  131.                             {% if ChildCategory == "ポケモン" %}
  132.                                 {% for MagoCategory in ChildCategory.children %}
  133.                                     {% if MagoCategory == "レアリティ"%}
  134.                                         {% for HimagoCategory in MagoCategory.children %}
  135.                                             <option value="{{ HimagoCategory.id }}" {% if category_id5 == HimagoCategory.id %}selected
  136.                                             {% endif %}>{{ HimagoCategory }}</option>
  137.                                         {% endfor %}
  138.                                     {% endif %}
  139.                                 {% endfor %}
  140.                             {% endif %}
  141.                         {% endfor %}
  142.                     {% endif %}
  143.                 {% endfor %}
  144.             </select><br>
  145.             </div>
  146.     
  147.             <div>
  148.             <button type="submit" class="search-sub">
  149.                     <img src="/html/user_data/assets/img/searchbtn.png" alt="">
  150.             </button>
  151.             </div>
  152.     
  153.     
  154.         </form>
  155.     </div>
  156. {% else %}
  157.     <div class="wback searchbox">
  158.         <h2 class="maru">商品検索</h2>
  159.         <form method="get" action="/products/list">
  160.     
  161.             <input type="hidden" name="category_id" id="category_id" value="428">
  162.             <input type="search" name="name" maxlength="50" class="search-name" placeholder="キーワードを入力" value="{{ name }}"><Br>
  163.             <p>検索するカード</p>
  164.             <select name="type" id="type">
  165.                 {# type一致でselectedする #}
  166.                 <option value="0" {% if type == 0 %}selected{% endif %}>選択して下さい</option>
  167.                 <option value="1" {% if type == 1 %}selected{% endif %}>ヴァイスシュヴァルツ</option>
  168.                 <option value="2" {% if type == 2 %}selected{% endif %}>ポケモン</option>
  169.             </select>
  170.             
  171.             <div class="search-weis">
  172.             <p>タイトル</p>
  173.             <select name="category_id2">
  174.                 <option value="">ヴァイスシュヴァルツから検索</option>
  175.                 {% for Category in Categories %}
  176.                     {% if Category == "販売" %}
  177.                         {% for ChildCategory in Category.children %}
  178.                            
  179.                             {% if ChildCategory == "ヴァイスシュヴァルツ" %}
  180.                                 {% for MagoCategory in ChildCategory.children %}
  181.                                     {% if MagoCategory == "シュヴァルツサイド" or MagoCategory == "ヴァイスサイド"%}
  182.                                         {% for HimagoCategory in MagoCategory.children %}
  183.                                             <option value="{{ HimagoCategory.id }}" {% if category_id2 == HimagoCategory.id %}selected{% endif %}>{{ HimagoCategory }}</option>
  184.                                         {% endfor %}
  185.                                     {% endif %}
  186.                                 {% endfor %}
  187.                             {% endif %}
  188.                         {% endfor %}
  189.                     {% endif %}
  190.                 {% endfor %}
  191.             </select><br>
  192.             
  193.             <p>レアリティ</p>
  194.             <select name="category_id3">
  195.                 <option value="">レアリティを選択</option>
  196.                 {% for Category in Categories %}
  197.                     {% if Category == "販売" %}
  198.                         {% for ChildCategory in Category.children %}
  199.                            
  200.                             {% if ChildCategory == "ヴァイスシュヴァルツ" %}
  201.                                 {% for MagoCategory in ChildCategory.children %}
  202.                                     {% if MagoCategory == "レアリティ"%}
  203.                                         {% for HimagoCategory in MagoCategory.children %}
  204.                                             <option value="{{ HimagoCategory.id }}" {% if category_id5 == HimagoCategory.id %}selected{% endif %}>{{ HimagoCategory }}</option>
  205.                                         {% endfor %}
  206.                                     {% endif %}
  207.                                 {% endfor %}
  208.                             {% endif %}
  209.                         {% endfor %}
  210.                     {% endif %}
  211.                 {% endfor %}
  212.             </select><br>
  213.             </div>
  214.             <div class="search-poke">
  215.             <p>タイトル</p>
  216.             <select name="category_id4">
  217.                 <option value="">ポケモンから選択</option>
  218.                 {% for Category in Categories %}
  219.                     {% if Category == "販売" %}
  220.                         {% for ChildCategory in Category.children %}
  221.                             {% if ChildCategory == "ポケモン" %}
  222.                                 {% for MagoCategory in ChildCategory.children %}
  223.                                     {% if MagoCategory != "レアリティ" %}
  224.                                         <option value="{{ MagoCategory.id }}" {% if category_id4 == MagoCategory.id %}selected{% endif %}>{{ MagoCategory }}</option>
  225.                                     {% endif %}
  226.                                 {% endfor %}
  227.                             {% endif %}
  228.                         {% endfor %}
  229.                     {% endif %}
  230.                 {% endfor %}
  231.             </select><br>
  232.             
  233.             <p>レアリティ</p>
  234.             <select name="category_id5">
  235.                 <option value="">レアリティを選択</option>
  236.                 {% for Category in Categories %}
  237.                     {% if Category == "販売" %}
  238.                         {% for ChildCategory in Category.children %}
  239.                            
  240.                             {% if ChildCategory == "ポケモン" %}
  241.                                 {% for MagoCategory in ChildCategory.children %}
  242.                                     {% if MagoCategory == "レアリティ"%}
  243.                                         {% for HimagoCategory in MagoCategory.children %}
  244.                                             <option value="{{ HimagoCategory.id }}" {% if category_id5 == HimagoCategory.id %}selected{% endif %}>{{ HimagoCategory }}</option>
  245.                                         {% endfor %}
  246.                                     {% endif %}
  247.                                 {% endfor %}
  248.                             {% endif %}
  249.                         {% endfor %}
  250.                     {% endif %}
  251.                 {% endfor %}
  252.             </select><br>
  253.             </div>
  254.             
  255.             <div>
  256.             {# tag_idがあればselected #}
  257.             {% if tag_id == 4 %}
  258.                 <input type="checkbox" id="tag_id" name="tag_id" value="4" checked/><label for="horns">この商品の傷有り商品を見る</label><Br>
  259.             {% else %}
  260.                 <input type="checkbox" id="tag_id" name="tag_id" value="4"/><label for="horns">この商品の傷有り商品を見る</label><Br>
  261.             {% endif %}
  262.             </div>
  263.     
  264.             <button type="submit" class="search-sub">
  265.                     <img src="/html/user_data/assets/img/searchbtn.png" alt="">
  266.             </button>
  267.     
  268.     
  269.         </form>
  270.     </div>
  271. {% endif %}