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.
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 style the search data
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");
Thanks 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”));
?>
Darn. We will have to revert to the code you had before and use PHP to trim the strings. I will need a clear run at this. Can I get back to you when I have an hour or so free (might be today, might be Sunday/Monday)?
Perfect, thanks for your help so far Trevor! 🙂
Hi
Are you able to give me access to the page where the code currently is (is it in a template php file). This might mean having ftp access.
Ok.
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 🙁
Just taken a look and works!!
I will have a go at getting the “cross” to work.
Thank you so much for your help Trevor.
Notice 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.
My guess is that Ross could knock something up in a jiffy to do that. I will ask him.
The topic ‘How to style the search data’ is closed to new replies.
© 2024 Search & Filter Support. All Rights Reserved.
This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
We also use cookies to store items in your cart as well as allowing your to login on the site.
You can adjust all of your cookie settings by navigating the tabs on the left hand side.
By continuing to use this site, you also agree to our Privacy Policy.
Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.
*Other cookies used for logging in and cart functions will only be used when you use those features and cannot be disabled.
If you disable these cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.
This website uses Google Analytics to collect anonymous information such as the number of visitors to the site, and the most popular pages.
Keeping this cookie enabled helps us to improve our website.
Please enable Strictly Necessary Cookies first so that we can save your preferences!
More information about our Cookie Policy