Forums › Forums › Search & Filter Pro › Dynamic filtering on custom template
Tagged: V3
- This topic has 13 replies, 3 voices, and was last updated 6 years, 10 months ago by
Ross.
-
Trevor(Private) August 14, 2018 at 4:15 pm #185535
Ah, well, you might be able to use this filter:
https://searchandfilter.com/documentation/action-filter-reference/#filter-input-object
To set the default value in that field, based on the page you are on.
Anonymous(Private) August 15, 2018 at 8:40 am #185620Hi Trevor,
I was able to get a default option selected through the code you provided. However, this did not change the state of the search form, meaning that the other selects in the filter form still had all the options, as if no country was selected. I will paste the code I used below;
function filter_input_object($input_object, $sfid) { if(($input_object['name']!='_sft_trip-country[]')||($input_object['type']!='select')) { $input_object['defaults'] = array('germany'); } return $input_object; }
As you can see, i’m manually selecting ‘germany’, because I could not get it to work dynamically with this code;
$input_object['defaults'] = array($country_choice);
Any ideas what i’m missing? Should I perhaps also change the url to add the search parameter like;
/?_sft_trip-country=$country_choice
Thanks in advance!
-
AuthorPosts