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 & Filter Pro How to show the currently selected title only

Viewing 10 posts - 11 through 20 (of 22 total)
  • Tom Thorley
    #108508

    This returns what looks like an empty array?

    Array
    (
    )
    1
    Trevor Moderator
    #108514

    You tried this?

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

    Yes this is what returned the empty array

    Trevor Moderator
    #108520

    It should not be empty if a search has been done.

    Tom Thorley
    #108528

    I see, well it’s in use with a category radio button field, not a search form. Do you think this is why it is returning empty?

    Link

    As you can see on this page under the “category +” button, this is what is being used. There is no search form currently.

    Trevor Moderator
    #108533

    The basic code shown will only work when the page the php is on has received a search query.

    Detecting what checkbox has been ticked on a current page can only be done in javascript (using the change listener).

    Tom Thorley
    #108535

    Okay, but the checkboxes are directly from the S&F Plugin shortcode so does it not use the same kind of query as a search?

    If it can’t be resolved with PHP, would you suggest a work around? I really want to get this to work because I am basing my whole search/browse functionality on S&F

    Trevor Moderator
    #108539
    This reply has been marked as private.
    Trevor Moderator
    #108546

    Great to speak with you Tom. I will leave you to experiment with what I suggested and then get back to me.

    Tom Thorley
    #108628

    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

Viewing 10 posts - 11 through 20 (of 22 total)

The topic ‘How to show the currently selected title only’ is closed to new replies.