Forums Forums Search & Filter Pro Dynamic filtering on custom template

Tagged: 

Viewing 10 posts - 1 through 10 (of 13 total)
  • Trevor
    #185521

    Let us take this one step at a time. The taxonomy you refer to here:

    How do we make sure a visitor can only filter in the desired taxonomy?

    Is that the country (which you said was also an ACF field)?

    Anonymous
    #185526

    Hi Trevor,

    Thanks for the quick reply.
    Yes, that would be a country. To be clear; the ACF field is just a taxonomy select field, in order to let the client choose the country to base the page on.

    Trevor
    #185531

    Is that taxonomy a field within the form on the page (or could it be made to be, even if hidden)?

    Anonymous
    #185533

    It’s not a field yet, but I could make a field for it, sure. How would we fill it with the right value though?

    Trevor
    #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
    #185620

    Hi 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!

    Anonymous
    #185622
    This reply has been marked as private.
    Trevor
    #185639
    This reply has been marked as private.
    Anonymous
    #185967

    Hi Trevor/Ross, do you have any updates on this issue?

    Ross Moderator
    #185975
    This reply has been marked as private.
Viewing 10 posts - 1 through 10 (of 13 total)