Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search Search Results for 'current_query'

Viewing 10 results - 321 through 330 (of 374 total)
  • Author
    Search Results
  • #59294

    In reply to: Different Results.php


    bezbeli
    Participant
    This reply has been marked as private.
    #58751

    In reply to: default value


    Trevor
    Moderator

    Nor am I 🙁 I have done some, but not a lot. My guess, for you, you would need something more like:

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1726)->current_query();
    if (!$sf_current_query->is_filtered()) {
    // put your javascript here
    }
    #58717

    In reply to: default value


    Fred Malinge
    Participant

    Hi,
    Thanks ,

    I’m not a developer with JavaScript, but I’ll try.
    I have to test with.:
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1726)->current_query();
    if ($sf_current_query->is_filtered()) {
    // do the loop
    } else {
    // initialize data with javascript
    }
    where do I insert the javascript?
    for exemple to set a date with the today’s date (_sfm_my_date)
    Thanks

    #57149

    Tim Houghton
    Participant

    Actually I spoke to soon.

    The if statement in this thread doesn’t quite work. It partly works insofar as there are no results on initial page load, and if I choose a category or tag then results appear. So far so good. But if I just search for word there are no results at all.

    If I remove the if statement then I do get results.

    Is if ($sf_current_query->is_filtered()) supposed to trigger if a word has been searched for?

    #56017

    Trevor
    Moderator

    In PHP you need to take the string and modify it. The first thing is to remove the Location: string. So, you use the PHP Search function to find the :, like this:

    $return_string = $sf_current_query->get_fields_html(array("_sft_locatie");
    $colon_pos = strpos($return_string, ":");

    Then you fetch the right most part of the return_string after the colon:

    $return_string_trim = substr($return_string, $colon_pos+1);
    

    Then you replace the commas with <br />:

    $return_string_html = str_replace(",", "<br />", $return_string_trim);
    

    And then you return the string:

    return $return_string_html;
    

    At least, I think ….

    #55931

    Edward
    Participant

    So this is kind of similar to a question I’ve already asked. But now I’m struggling with the styling of the echo.

    To echo the checked boxes I use the following code:

    function locaties_search() {
        global $searchandfilter;
        $sf_current_query = $searchandfilter->get(3403)->current_query();
        return $sf_current_query->get_fields_html(array("_sft_locatie"), array('show_all_if_empty' => false));
    }
    
    add_shortcode('locatiesearch', 'locaties_search');

    And then I use the following shortcode to echo the results:
    <?php echo do_shortcode('[locatiesearch]'); ?>

    Right now it’s displaying the results like:
    Location:Location-x, Location-y

    What I would like is to have it just echo like so:
    Location-x
    Location-y

    What code should I use?

    #52218

    In reply to: Getting value from url


    Edward
    Participant

    Well, that breaks the code, the part where the echo should be doens’t show anymore. The rest doesn’t show neither.

    <?php global $searchandfilter;
    $sf_current_query = $searchandfilter->get(15)->current_query()->get_array();
    foreach($sf_current_query as $key) {
      echo '<div>' . $key['name'] . '</div>';
      echo '<div>' . $key['active_terms'][0]['name'] . '</div>';
    } ?>
    #52114

    In reply to: Getting value from url


    Trevor
    Moderator

    What does this give?

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(339)->current_query()->get_array();
    foreach($sf_current_query as $key) {
      echo '<div>' . $key['name'] . '</div>';
      echo '<div>' . $key['active_terms'][0]['name'] . '</div>';
    }
    #52093

    In reply to: Getting value from url


    Trevor
    Moderator

    What does this give you?

    <?php
       //Get a multiple fields values by passing an array of field names
       //replace 1526 with the ID of your search form
    	global $searchandfilter;
    	$sf_current_query = $searchandfilter->get(15)->current_query();
    	print_r($sf_current_query);
    ?>
    #52078

    In reply to: Getting value from url


    Trevor
    Moderator

    This?

    <?php
       //Get a multiple fields values by passing an array of field names
       //replace 1526 with the ID of your search form
    	global $searchandfilter;
    	$sf_current_query = $searchandfilter->get(15)->current_query();
    	print_r($sf_current_query->get_fields_html(array(), array('show_all_if_empty' => false)));
    ?>
Viewing 10 results - 321 through 330 (of 374 total)