Forums Forums Search Search Results for 'current_query'

Viewing 10 results - 241 through 250 (of 344 total)
  • Author
    Search Results
  • #116180

    Trevor
    Participant

    Hi

    You need to make sure that you have followed the Customization guide here.

    Edit the results.php file like this (where 1234 is changed for the actual ID of your form):

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1234)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
      // any other message here if no search has been made (can be empty)
    } else {
      // your results.php code here
    }
    #109934

    Anonymous
    Inactive
     while ( $sf_current_query->have_posts() ) : $sf_current_query->the_post();
      $index = $sf_current_query->current_post + 1; ?>
      section:nth-child(<?php echo $index; ?>) > .category {
      background:url('<?php the_post_thumbnail_url('large'); ?>');
      box-shadow: inset 0px 0px 400px 110px rgba(0, 0, 0, .7);
    }
    <?php endwhile;
    #108703

    Anonymous
    Inactive

    GOT IT!!!

    global $searchandfilter;
    
     $sf_current_query = $searchandfilter->get(504)->current_query()->get_array();
    
     if (empty($sf_current_query)) {
        echo ('All Articles');
        }
     else {
       echo $sf_current_query['_sft_category']['active_terms'][0]['name'];
     }

    The above code worked like a charm, I also use the “Archive” setting as you suggested! Thanks so much for your help on this one!! Finally working properly!! 🙂

    #108628

    Anonymous
    Inactive

    Hi Trevor,

    UPDATE! I’ve managed to half get it working!!!

    It now works for all categories except the “All Categories” one, this seems to behave differently to the others and the code I have used doesn’t bring it in:

    $sf_current_query = $searchandfilter->get(766)->current_query()->get_array();
     echo $sf_current_query['_sft_category']['active_terms'][0]['name'];

    I’ve left the printr statement in on the live site so you can get a picture of what is happening. I presume there may need to be an if statement added but I have yet to be able to pull in the “All categories” heading… I was however thinking of just hard coding a title in as it is only one title?? But i’m not sure how I would do it. I’m sure there is a “proper” fix to this though?

    I hope you have a good weekend

    #108514

    Trevor
    Participant

    You tried this?

    <?php
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(504)->current_query()->get_array();
    echo '<pre>',print_r($sf_current_query),'</pre>';
    ?>
    #108481

    Trevor
    Participant

    Ah, I see the erro. Not sure how many steps back you will need to take though.

    $sf_current_query = $searchandfilter->get(504)->current_query()->get_array();
    

    And look at what is in THAT array using print_r.

    #108461

    Trevor
    Participant

    Try this then:

    <?php
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(504)->current_query();
    echo $sf_current_query['_sft_category'][0]['taxonomy_name'];
    ?>
    #108447

    Anonymous
    Inactive
    <?php
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(504)->current_query();
    echo $sf_current_query['_sft_category']['taxonomy_name'];
    ?>

    This code gives me an error… although it does look like this should work?

    #108444

    Trevor
    Participant

    If you echo this:

    $sf_current_query['_sft_category']['taxonomy_name']

    What does it give you?

    #108431

    Anonymous
    Inactive

    Okay, I have used the following code to display the array:

    <?php echo '<pre>',print_r($sf_current_query),'</pre>';?>

    This displays the following:

    Search_Filter_Active_Query Object
    (
        [sfid] => 504
        [is_set:Search_Filter_Active_Query:private] => 1
        [query_array:Search_Filter_Active_Query:private] => Array
            (
            )
    
        [form_fields:Search_Filter_Active_Query:private] => Array
            (
                [_sft_category] => Array
                    (
                        [type] => category
                        [input_type] => radio
                        [heading] => Categories
                        [accessibility_label] => 
                        [all_items_label] => All Articles
                        [show_count] => 1
                        [hide_empty] => 1
                        [hierarchical] => 0
                        [include_children] => 1
                        [drill_down] => 0
                        [sync_include_exclude] => 1
                        [combo_box] => 0
                        [operator] => or
                        [order_by] => default
                        [order_dir] => asc
                        [exclude_ids] => 
                        [taxonomy_name] => category
                    )
    
            )
    

    (plus lots more)

    So what I want is the taxonomy name field but I have no idea how to access this field and echo into my template? Any help here would be much appreciated, I understand this may be out of the scope of support but if it’s something simple that you might know you could really help me out a lot.

    Thanks

Viewing 10 results - 241 through 250 (of 344 total)