Forums › Forums › Search & Filter Pro › How to style the search data
- This topic has 29 replies, 2 voices, and was last updated 8 years, 7 months ago by Anonymous.
-
Anonymous(Private) April 21, 2016 at 1:25 pm #43504
Hi,
I have used the following code to show the specific taxonomy fields within the search form:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(339)->current_query(); echo $sf_current_query->get_fields_html( array("_sft_length", "_sft_rate", "_sft_guest", "_sft_location", "_sft_toy") ); ?>
However this code displays the full list of fields continuously.
Is there a way to style and list only the content from each taxonomy used for a search, after form submission?
Further to this, once the content is displaying independently is there a way to assign a small “cross” to be able to remove this specific field from the search?
Page found at http://www.cascadetest.co.uk/oneocean.com/charter-overview/
Trevor(Private) April 21, 2016 at 2:45 pm #43524I think that these are 2 separate questions? Let’s take the first one first. If I click on a yacht length, I might see this:
Yacht Length: 40-50m
Yacht Rate: All Yacht Rates
Yacht Guests: All Yacht Guests
Yacht Locations: All Yacht Locations
Yacht Hero Toys: All Yacht Hero Toys Found 6 Results
Page 1 of 1You want it to show something like this:
Yacht Length: 40-50m
Found 6 Results
Page 1 of 1And what if it is the first time on the page, with no search? Only this to show?
Found 10 Results
Page 1 of 2Anonymous(Private) April 21, 2016 at 2:57 pm #43530Correct, although I’d like to be able to remove the “Yacht Length” and all subsequent category titles all together.
Eventually I’d like it to show:
x 40-50m
Found 6 results
Page 1 of 1Where the “x” is an active link to remove it from the active search.
And correct about the first time on the page.
Trevor(Private) April 21, 2016 at 4:46 pm #43562Hi
Ross tells me that there is additional functionality on this filter, he says this will be useful to you:
get_fields_html(array(), array('show_all_if_empty' => false))
Instead of what you used. As to the other x link feature, he says it is not there now, but is coming (as is an easier way to what you have above), but this may be useful to you:
Anonymous(Private) April 21, 2016 at 5:04 pm #43565Hi,
I’ve added the code but it seems to be throwing an error on the array. Am I missing something?
<?php
//Get a multiple fields values by passing an array of field names
//replace1526
with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(339)->current_query();
echo $sf_current_query->get_fields_html(array(), array(‘show_all_if_empty’ => false)
);
?>I’ve also added the code from the supplied link but it throws back the following error:
array(2) { [“_sft_length”]=> array(5) { [“name”]=> string(13) “Yacht Lengths” [“singular_name”]=> string(12) “Yacht Length” [“all_items_label”]=> string(17) “All Yacht Lengths” [“type”]=> string(8) “taxonomy” [“active_terms”]=> array(1) { [0]=> array(4) { [“id”]=> int(6) [“name”]=> string(6) “40-50m” [“value”]=> string(6) “40-50m” [“count”]=> int(5) } } } [“_sft_toy”]=> array(5) { [“name”]=> string(15) “Yacht Hero Toys” [“singular_name”]=> string(14) “Yacht Hero Toy” [“all_items_label”]=> string(19) “All Yacht Hero Toys” [“type”]=> string(8) “taxonomy” [“active_terms”]=> array(1) { [0]=> array(4) { [“id”]=> int(16) [“name”]=> string(7) “Freezer” [“value”]=> string(7) “freezer” [“count”]=> int(5) } } } }Found on the same web link as before.
Anonymous(Private) April 22, 2016 at 9:09 am #43600Trevor, works brilliantly, thanks.
The only other thing which we need to be able to do is to remove the taxonomy title when it reveals.
Currently when a search is made it shows:
“Yacht Length: 40-50m”
Is there a way to remove the “Yacht Length” so it only shows the search data?
-
AuthorPosts