Guest User

Untitled

a guest
Apr 21st, 2016
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.99 KB | None | 0 0
  1. FUNCTIONS.php
  2.  
  3. function footyboots_construct_filter_query() {
  4. if(isset($_GET['producent'])) {
  5. $producentGET1 = $_GET['producent'];
  6. $producentGET = true;
  7. } else {
  8. $producentGET = false;
  9. }
  10. if(isset($_GET['produkttype'])) {
  11. $produkttypeGET1 = $_GET['produkttype'];
  12. $produkttypeGET = true;
  13. } else {
  14. $produkttypeGET = false;
  15. }
  16. if(isset($_GET['farve'])) {
  17. $farveGET1 = $_GET['farve'];
  18. $farveGET = true;
  19. } else {
  20. $farveGET = false;
  21. }
  22. if(isset($_GET['knopkonfiguration'])) {
  23. $knopkonfigurationGET1 = $_GET['knopkonfiguration'];
  24. $knopkonfigurationGET = true;
  25. } else {
  26. $knopkonfigurationGET = false;
  27. }
  28. if(isset($_GET['tilbud'])) {
  29. $tilbudGET1 = $_GET['tilbud'];
  30. $tilbudGET = true;
  31. } else {
  32. $tilbudGET = false;
  33. }
  34.  
  35. $argsFilter = array(
  36. 'post_type' => 'fodboldstoevle',
  37. 'showposts' => -1,
  38. 'meta_query' => array(
  39. ($producentGET) ? array('key' => 'footyboots_producent','value' => $producentGET1) : null,
  40. ($produkttypeGET) ? array('key' => 'footyboots_produkttype','value' => $produkttypeGET1) : null,
  41. ($farveGET) ? array('key' => 'footyboots_farve','value' => $farveGET1) : null,
  42. ($knopkonfigurationGET) ? array('key' => 'footyboots_knopkonfiguration','value' => $knopkonfigurationGET1) : null,
  43. ($tilbudGET) ? array('key' => 'footyboots_tilbud','value' => $tilbudGET1) : null,
  44. ),
  45.  
  46. );
  47.  
  48. print_r($argsFilter);
  49. return $argsFilter;
  50. }
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57. STOEVLEFILTER.php
  58.  
  59. <?php
  60. /* Template Name: Fodboldstøvle filter */
  61. get_header();
  62. ?>
  63. <div class="container">
  64. <h1>Støvler</h1>
  65. <div class="row">
  66. <div class="col-md-3">
  67. <button class="filter-btn visible-xs visible-sm" data-toggle="collapse" data-target="#filter-md">Vis filter</button>
  68. <div id="filter-md" class="sidebar collapse.in">
  69. <form action="<?php the_permalink(); ?>" method="GET">
  70. <section>
  71. <b>Pris</b>
  72. <ul class="filter-checkboxes">
  73. <li><input type="checkbox" id="checkboxTilbud" name="tilbud[]" value="tilbud"><label for="checkboxTilbud"><span></span>Vis kun tilbudsvarer</label></li>
  74. </ul>
  75. </section>
  76. <section>
  77. <b>Mærke</b>
  78. <ul class="filter-checkboxes">
  79. <li><input type="checkbox" id="checkboxAdidas" name="producent[]" class="producent123" value= adidas"><label for="checkboxAdidas"><span></span>adidas</label></li>
  80. <li><input type="checkbox" id="checkboxNike" name="producent[]" class="producent123" value="Nike"><label for="checkboxNike"><span></span>Nike</label></li>
  81. <li><input type="checkbox" id="checkboxPuma" name="producent[]" class="producent123" value="Puma"><label for="checkboxPuma"><span></span>Puma</label></li>
  82. </ul>
  83. </section>
  84. <section>
  85. <b>Produkt type</b>
  86. <ul class="filter-checkboxes">
  87. <li><input type="checkbox" id="checkboxStoevler" name="produkttype[]" value="Fodboldstøvler"><label for="checkboxStoevler"><span></span>Fodboldstøvler</label></li>
  88. <li><input type="checkbox" id="checkboxIndendoers" name="produkttype[]" value="Indendørssko"><label for="checkboxIndendoers"><span></span>Indendørssko</label></li>
  89. <li><input type="checkbox" id="checkboxKunstgraes" name="produkttype[]" value="Kunstgræsstøvler"><label for="checkboxKunstgraes"><span></span>Kunstsgræsstøvler</label></li>
  90. <li><input type="checkbox" id="checkboxGrus" name="produkttype[]" value="Grusbanestøvler"><label for="checkboxGrus"><span></span>Grusbanestøvler</label></li>
  91. </ul>
  92. </section>
  93. <section>
  94. <b>Farve</b>
  95. <ul class="filter-checkboxes">
  96. <li><input type="checkbox" id="checkboxBlaa" name="farve[]" value="Blå"><label for="checkboxBlaa"><span></span>Blå</label></li>
  97. <li><input type="checkbox" id="checkboxBrun" name="farve[]" value="Brun"><label for="checkboxBrun"><span></span>Brun</label></li>
  98. <li><input type="checkbox" id="checkboxGraa" name="farve[]" value="Grå"><label for="checkboxGraa"><span></span>Grå</label></li>
  99. <li><input type="checkbox" id="checkboxGroen" name="farve[]" value="Grøn"><label for="checkboxGroen"><span></span>Grøn</label></li>
  100. <li><input type="checkbox" id="checkboxGul" name="farve[]" value="Gul"><label for="checkboxGul"><span></span>Gul</label></li>
  101. <li><input type="checkbox" id="checkboxGuld" name="farve[]" value="Guld"><label for="checkboxGuld"><span></span>Guld</label></li>
  102. <li><input type="checkbox" id="checkboxHvid" name="farve[]" value="Hvid"><label for="checkboxHvid"><span></span>Hvid</label></li>
  103. <li><input type="checkbox" id="checkboxLilla" name="farve[]" value="Lilla"><label for="checkboxLilla"><span></span>Lilla</label></li>
  104. <li><input type="checkbox" id="checkboxOrange" name="farve[]" value="Orange"><label for="checkboxOrange"><span></span>Orange</label></li>
  105. <li><input type="checkbox" id="checkboxRoed" name="farve[]" value="Rød"><label for="checkboxRoed"><span></span>Rød</label></li>
  106. <li><input type="checkbox" id="checkboxSort" name="farve[]" value="Sort"><label for="checkboxSort"><span></span>Sort</label></li>
  107. <li><input type="checkbox" id="checkboxSoelv" name="farve[]" value="Sølv"><label for="checkboxSoelv"><span></span>Sølv</label></li>
  108. </ul>
  109. </section>
  110. <section>
  111. <b>Knopkonfiguration</b>
  112. <ul class="filter-checkboxes">
  113. <li><input type="checkbox" id="checkboxAG" name="knopkonfiguration[]" value="AG"><label for="checkboxAG" data-toggle="tooltip" data-placement="right" title="Artificial Grass - Kunstgræs"><span></span>AG</label></li>
  114. <li><input type="checkbox" id="checkboxFG" name="knopkonfiguration[]" value="FG"><label for="checkboxFG" data-toggle="tooltip" data-placement="right" title="Firm Ground - Naturlige græsbaner"><span></span>FG</label></li>
  115. <li><input type="checkbox" id="checkboxHG" name="knopkonfiguration[]" value="HG"><label for="checkboxHG" data-toggle="tooltip" data-placement="right" title="Hard Ground - Grus & kunstgræs"><span></span>HG</label></li>
  116. <li><input type="checkbox" id="checkboxIC" name="knopkonfiguration[]" value="IC"><label for="checkboxIC" data-toggle="tooltip" data-placement="right" title="Indendørssko"><span></span>IC</label></li>
  117. <li><input type="checkbox" id="checkboxSG" name="knopkonfiguration[]" value="SG"><label for="checkboxSG" data-toggle="tooltip" data-placement="right" title="Soft Ground - Blød vandet jord, typisk jernknopper"><span></span>SG</label></li>
  118. <li><input type="checkbox" id="checkboxTF" name="knopkonfiguration[]" value="TF"><label for="checkboxTF" data-toggle="tooltip" data-placement="right" title="Artificial Grass - Kunstgræs"><span></span>TF</label></li>
  119. </ul>
  120. </section>
  121. <input class="filter-btn" type="submit" id="filter_submit_btn" value="Find støvle">
  122. </form>
  123. </div>
  124. </div>
  125. <div class="col-md-9">
  126. <div class="row products">
  127. <?php
  128. $filterQuery = new WP_Query(footyboots_construct_filter_query());
  129. if($filterQuery->have_posts()):
  130. while($filterQuery->have_posts() ): $filterQuery->the_post();?>
  131. <div class="col-md-3 col-sm-6">
  132. <div class="product-preview">
  133. <?php
  134. if(footyboots_check_tilbud(rwmb_meta('footyboots_tilbudprocent'))) { ?>
  135. <div class="tilbud">
  136. <?php
  137. echo '-' . rwmb_meta('footyboots_tilbudprocent') .'%';
  138. ?>
  139. </div>
  140. <?php
  141. }
  142. footyboots_return_first_image(rwmb_meta('footyboots_produktbilleder'));
  143. ?>
  144. <b><?php echo rwmb_meta('footyboots_producent'); ?></b>
  145. <small><?php echo rwmb_meta('footyboots_navn') .' '.footyboots_implode('/', rwmb_meta('footyboots_knopkonfiguration')) .' '. footyboots_implode('/', rwmb_meta('footyboots_farve')); ?></small>
  146. <div class="text-center">
  147. <a href="<?php echo the_permalink(); ?>" class="btn btn-danger "><span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span> DKK <?php echo rwmb_meta('footyboots_pris'); ?>,-</a>
  148. </div>
  149. </div>
  150. </div>
  151. <?php
  152. endwhile;
  153. else:
  154. ?>
  155. Ingen støvler matcher din søgning:(
  156. <?php
  157. endif;
  158.  
  159. wp_reset_postdata();
  160. ?>
  161. </div>
  162. </div>
  163. </div>
  164. </div>
  165. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment