Forums Forums Search Search Results for 'sf_current_query'

Viewing 10 results - 271 through 280 (of 318 total)
  • Author
    Search Results
  • #64663

    Anonymous
    Inactive

    Is this also work in sf_input_object_pre that you gave me?

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1726)->current_query();

    #64374

    Trevor
    Participant

    Hi

    It all seems to work for me?

    As to not showing results when the page loads, you need to edit the results.php file, like this:

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1726)->current_query();
    if (!$sf_current_query->is_filtered()) {
    // put anything you want instead of the results for the page loading without query parameter
    } else {
    // put the output part of the results.php here
    }
    #58751

    In reply to: default value


    Trevor
    Participant

    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


    Anonymous
    Inactive

    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

    Anonymous
    Inactive

    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
    Participant

    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

    Anonymous
    Inactive

    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


    Anonymous
    Inactive

    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
    Participant

    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
    Participant

    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);
    ?>
Viewing 10 results - 271 through 280 (of 318 total)