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.
-
Trevor(Private) April 22, 2016 at 10:44 am #43625
Hi, 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");
Anonymous(Private) April 22, 2016 at 11:01 am #43630Thanks for this code, I had to adjust the code to add extra closing brackets for the STRING (below), unfortunately this results in the same data being given.
“Yacht Length: 40-50m”
<?php
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”));
?>Trevor(Private) April 26, 2016 at 10:44 am #43915Ok.
So, this is the code I made:
global $searchandfilter; $sf_current_query = $searchandfilter->get(339)->current_query()->get_array(); foreach($sf_current_query as $key) { echo '<div>' . $key['active_terms'][0]['name'] . '</div>'; }
If you wanted to put the X before each, replace the echo line with something like this:
echo '<div><a id="executeMyCodeLink" href="#">X</a> ' . $key['active_terms'][0]['value'] . '</div>';
Where the code to add to the page would be something like this
<script> $('#executeMyCodeLink').click(function(event) { /// Your code here }); </script>
But that is beyond the scope of what I can do easily 🙁
Trevor(Private) April 26, 2016 at 11:02 am #43922Notice how I put some divs in there, so you can add a style class and style it how you want. I am sure that there will be a way to do the js.
It would work like this, is my guess.
Set the form element back to default value and then re-submit the form.
-
AuthorPosts