Forums Forums Search & Filter Pro Change default selection of checkbox filter

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Anonymous
    #266046

    I am trying to change the default landing state of a page from ‘all’ to a sepcific category or value. (i.e education) I am using a shortcode and am customising the php file. I am using a custom field of ‘projects’ and filtering these using a checkbox filter by ‘project-type’ (eg. education, commercial etc.)

    Reading through the forum I think I need to use a combination of these three snippets but cannot put them together. Can anyone help out?

    1.

    function filter_function_name($input_object, $sfid)
    {
    if($input_object[‘name’]==’_sft_project-type’)||($input_object[‘type’]!=’select’))
    {
    //udpate this field before rendering
    }

    return $input_object;
    }
    add_filter(‘sf_input_object_pre’, ‘filter_function_name’, 10, 2);

    2.

    $input_object[‘defaults’] = array(“education”);

    3.

    //Get an array of objects containing data for the current search/filter
    //replace 1526 with the ID of your search form
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(43)->current_query();
    echo $sf_current_query->is_filtered();

    Trevor
    #266082

    I agree with the logic, and indeed I have tried to do this myself as the solution to this same question by other users previously. It should work, but it does not, sadly.

    Setting a default value is not possible with the current version of the plugin, but is something we intend to add in V3, due in a few months.

    Anonymous
    #266084

    Thanks Trevor. That will at least save me wasting any more time.

Viewing 3 posts - 1 through 3 (of 3 total)