Forums › Forums › Search & Filter Pro › Chosen filters
- This topic has 5 replies, 2 voices, and was last updated 6 years, 8 months ago by Trevor.
-
Anonymous(Private) March 17, 2018 at 2:19 pm #166552
Is it possible to make something like this:
https://imgur.com/a/12vDrI would like some help if it’s possible.
Thanks!
Trevor(Private) March 19, 2018 at 11:58 am #166804With some custom coding, it is partly possible, but it is not easy, and so not included in our support. We plan to make it a feature of V3 (in development).
This documentation may be what you are looking for (note, if you are using Ajax to refresh the page, any such output of the query needs to be inside the Ajax container):
https://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/
There are many snippets also on this forum. Try this search:
https://support.searchandfilter.com/forums/search/current_query/
You need to fetch the values from the taxonomy form fields. Be aware that some search terms will be held as arrays, and not single strings/values.
Anonymous(Private) March 19, 2018 at 1:29 pm #166837Thanks Trevor. I’m pretty new to PHP so I hope you dont mind me asking questions.
I got this code:
global $searchandfilter; $sf_current_query = $searchandfilter->get(3301)->current_query()->get_array(); foreach($sf_current_query as $key) { $type = $key['type']; $name = $key['active_terms'][0]['name']; $name1 = $key['active_terms'][1]['name']; echo '<button class="' . $type . '">'; echo $name; if ($name1 == NULL) { } else { echo ' - '; echo $name1; } echo '</button>'; }
I want the id of the button to be the array name.
Like:<button id="_sfm_prijsklasse" class="post_meta">
<button id="_sft_category" class="taxonomy">
How can I do this?
Anonymous(Private) March 20, 2018 at 10:03 am #167030Thanks this code is doing the job for me:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(3301)->current_query()->get_array(); foreach ($sf_current_query as $key => $value) { $type = $value['type']; $valuei = $value['active_terms'][0]['value']; $valuei1 = $value['active_terms'][1]['value']; $name = $value['active_terms'][0]['name']; $name1 = $value['active_terms'][1]['name']; if ($key == '_sft_category') { if ($name1 == NULL) { echo '<button id="'.$key.'" class="but'.$type.'">'; echo $name; echo '</button>'; } else { echo '<button id="'.$key.'" class="but'.$type.'">'; echo $name; echo '</button>'; echo '<button id="'.$key.'" class="but'.$type.'">'; echo $name1; echo '</button>'; } } if ($key == '_sft_materiaalsoorten') { echo '<button id="'.$key.'" class="but'.$type.'">'; echo $name; echo '</button>'; } if ($key == '_sfm_prijsklasse') { if ($valuei == 0) { echo ''; } else { echo '<button id="'.$key.'" class="but'.$type.'">'; echo 'Prijsklasse: '; echo $name; echo ' vanaf'; echo '</button>'; } if ($valuei1 == 50000) { echo ''; } else { echo '<button id="'.$key.'" class="but'.$type.'">'; echo 'Prijsklasse: '; echo $name1; echo ' tot'; echo '</button>'; } } if ($key == '_sfm_vrije_valhoogte') { if ($valuei == 0) { echo ''; } else { echo '<button id="'.$key.'" class="but'.$type.'">'; echo 'Valhoogte: '; echo $name; echo ' vanaf'; echo '</button>'; } if ($valuei1 == 300) { echo ''; } else { echo '<button id="'.$key.'" class="but'.$type.'">'; echo 'Valhoogte: '; echo $name1; echo ' tot'; echo '</button>'; } } if ($key == '_sfm_beschikbare_obstakelvrije_ruimte') { if ($valuei == 0) { echo ''; } else { echo '<button id="'.$key.'" class="but'.$type.'">'; echo 'Beschikbare obstakelvrije ruimte: '; echo $name; echo ' vanaf'; echo '</button>'; } if ($valuei1 == 350) { echo ''; } else { echo '<button id="'.$key.'" class="but'.$type.'">'; echo 'Beschikbare obstakelvrije ruimte: '; echo $name1; echo ' tot'; echo '</button>'; } } if ($key == '_sfm_leeftijdsindicatie_van') { if ($valuei == 0) { echo ''; } else { echo '<button id="'.$key.'" class="but'.$type.'">'; echo 'Leeftijdsindicatie: vanaf '; echo $name; echo '</button>'; } if ($valuei1 == 20) { echo ''; } else { echo '<button id="'.$key.'" class="but'.$type.'">'; echo 'Leeftijdsindicatie: tot '; echo $name1; echo '</button>'; } } } ?>
But what now? How can I make it when somebody clicks on a button the filter turns off?
-
AuthorPosts