Forums › Forums › Search & Filter Pro › displaying search terms without labels
Tagged: Accessing the Search Data, search terms
- This topic has 16 replies, 2 voices, and was last updated 8 years, 6 months ago by Trevor.
-
Anonymous(Private) May 18, 2016 at 1:50 am #45816
hi,
i’m using the Accessing the Search Data instructions to display the search terms in the heading.
everything is working fine. the only problem is i can’t seem to find a way to remove the label and display only the search term alone.
i’m using the echo $sf_current_query->get_field_string functionwould really appreciate help on this issue.
thanks, eli.
Trevor(Private) May 18, 2016 at 8:29 am #45831I have a feeling that you are asking a question similar to that asked in the thread that my solution in this post is found:
https://support.searchandfilter.com/forums/topic/how-to-style-the-search-data/page/2/#post-43915
I appreciate that some of the posts in that thread are marked as private, but I think the gist of it all is there. The user had a search and then the actual search terms used were repeated, without labels. Where a search term had not been used, it would not appear in this.
Trevor(Private) May 18, 2016 at 9:00 am #45833You would have to echo the ampersand between them.
The code in that post was specific to that user. If you are ALWAYS displaying the same 2 you have no need to loop through the array. Instead you could call them directly.
It took me quite a while to do that code, I am sure you can modify it.
Trevor(Private) May 29, 2016 at 10:20 am #46959OK
I have re-written that a bit and added a new line after each line output. It may not work, but it is better code:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(2327)->current_query()->get_array(); if (isset ($sf_current_query)) { foreach($sf_current_query as $key) { echo '<span class="results-term">' . $key['active_terms'][0]['name'] . '</span><br />'; } } ?>
-
AuthorPosts