Forums › Forums › Search & Filter Pro › How to style the search data
- This topic has 29 replies, 2 voices, and was last updated 9 years, 2 months ago by
Anonymous.
-
Trevor(Private) April 21, 2016 at 2:45 pm #43524
I 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?
Trevor(Private) April 22, 2016 at 10:44 am #43625Hi, can you try this code (it might be a step backwards, but bear with me):
global $searchandfilter; $sf_current_query = $searchandfilter->get(339)->current_query(); echo $sf_current_query->get_field_string("_sft_length", array("str" => "%2$s"); echo $sf_current_query->get_field_string("_sft_rate", array("str" => "%2$s"); echo $sf_current_query->get_field_string("_sft_guest", array("str" => "%2$s"); echo $sf_current_query->get_field_string("_sft_location", array("str" => "%2$s"); echo $sf_current_query->get_field_string("_sft_toy", array("str" => "%2$s");
-
AuthorPosts