Search Results for 'current_query'

Forums › Forums › Search › Search Results for 'current_query'

Viewing 10 results – 231 through 240 (of 385 total)
  • Author
    Search Results
  • #167030

    In reply to: Chosen filters


    Anonymous
    Inactive

    Thanks 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?

    #166839

    Trevor
    Participant

    For both questions, I am not skilled enough to do this, and this level of customization is not covered by support. You would need to use a third party freelance coder.

    With some custom coding, displaying the current filters is possible, but it is not easy. We plan to make it a feature of V3 (in development). But clearing them singly is not so easy. To clear them all (to reset the form), you would need to have a button that calls the form reset. That is possible. See this (and the post it refers to):

    https://support.searchandfilter.com/forums/topic/link-markup-for-reset-filter-button-that-is-outside-of-the-ui-markup/

    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.

    #166837

    In reply to: Chosen filters


    Anonymous
    Inactive

    Thanks 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?

    #166804

    In reply to: Chosen filters


    Trevor
    Participant

    With 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.


    Trevor
    Participant

    Ah, I see. You have three possible output combinations.

    Try this:

    <?php global $searchandfilter;
        $sf_current_query = $searchandfilter->get(2398)->current_query();
        $searchTerm = $sf_current_query->get_search_term();
          $args = array(
          "str"           => '%2$s', 
          "delim"         => array(", ", " - "), 
          "field_delim"       => ', ', 
          "show_all_if_empty"     => false 
        );
      ?>
    
    <?php global $wp_query;
    $fields_html = $sf_current_query->get_fields_html( array("_sft_clinical-area", "_sft_program", "_sft_type"), $args);
        if (( $searchTerm <> "" ) && ( $fields_html <> "" ) ){
          $field_delim = ', ';
        } else {
          $field_delim = '';
        }
    
              echo $wp_query->found_posts; ?>
              Search Results for <?php echo $searchTerm . $field_delim . $fields_html; ?>

    Maybe?


    Anonymous
    Inactive

    Hi there,

    First of all, this plugin has absolutely saved my life and I’m about to purchase the developer license so I can use it on all my client sites moving forward.

    However, I had a small little quandary. I’ve set up a custom search form that offers both a search bar as well as three filterable dropdowns.

    I’ve subsequently created a search results page that when queried returns results as well as a title that says:

    # for [search term(s)]

    (with the # being the number of search results for the term(s)).

    Now with this:

    <?php global $searchandfilter;
        $sf_current_query = $searchandfilter->get(2398)->current_query();
        $searchTerm = $sf_current_query->get_search_term();
          $args = array(
          "str"           => '%2$s', 
          "delim"         => array(", ", " - "), 
          "field_delim"       => ', ', 
          "show_all_if_empty"     => false 
        );
      ?>
    
    <?php global $wp_query;
              echo $wp_query->found_posts; ?>
              Search Results for <?php echo $searchTerm; ?> <?php echo $sf_current_query->get_fields_html( array("_sft_clinical-area", "_sft_program", "_sft_type"), $args);?>

    I’ve been able to output the search terms quite nicely, save for my one quandary. That if both a search term and filter are used, there is no comma between the two. I know this must be something easy that I’m missing, but I can’t seem to figure it out! Any help would be greatly greatly appreciated.

    Cheers!
    Connie

    #163328

    Trevor
    Participant

    I am not sure, but a good place to start is to echo the entire query array to the screen so you can see what everything is. Like this:

    $sf_current_query = $searchandfilter->get(53)->current_query();
    echo '<pre>';
    print_r($sf_current_query->get_array());
    echo '</pre>';
    #163253

    Anonymous
    Inactive

    Hello,

    In my search form UI I have a search form and multiple post meta acf checkbox

    I tried :

    <?php
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(53)->current_query();
    echo $sf_current_query->get_search_term();
    ?>

    It display only search terms of the search form, not post meta acf checkbox one !

    So I tried :

    <?php
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(53)->current_query();
    $args = array(
    “str” => ‘%2$s’,
    “delim” => array(“, “, ” – “),
    “field_delim” => ‘, ‘,
    “show_all_if_empty” => false
    );

    echo $sf_current_query->get_fields_html(
    array(“_sf_s”, “_sfm_nom-de-l-artiste”, “_sfm_prenom-du-commissaire”, “_sfm_lieu”, “_sfm_nom-du-medium”, “_sfm_forme-de-la-carte”, “_sfm_couleur”, “_sfm_ecole-du-commissaire”, “_sfm_jour-de-la-visite”, “_sfm_age-du-commissaire”),
    $args
    );
    ?>

    But it displays nothing !

    Can you help me and telle me what I did wrong ?

    Thank you very muche
    Best regards,
    Juke

    #162095

    Trevor
    Participant

    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.

    #161167

    Trevor
    Participant

    With some PHP coding on your part, yes you can display the query on the page. Note, if you are using Ajax to refresh the page, any such output of the query needs to be inside the Ajax container.

    The documentation is here:

    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 any form fields, and the search terms (they are held separately). The code to find and display taxonomies is different to that of custom fields, and be aware that some search terms will be held as arrays, and not single strings/values.

Viewing 10 results – 231 through 240 (of 385 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.