Support Forums

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 Customize Value Postfix

Viewing 10 posts - 1 through 10 (of 24 total)
  • Andrew Turner
    #214652

    Hi,

    I have a drop-down range setup for one of my ACF fields, using the Value Postifx option creates:

    5miles – 15miles

    But I want it to display as:

    5 – 15miles

    I’ve looked at using CSS pseudo techniques but I don’t believe it works with select options because they are generated by the OS/Browser.

    Any help appreciated.

    Trevor Moderator
    #214714

    Are you able to send me a live link/URL to your search page so I can take a look?

    Andrew Turner
    #214727
    This reply has been marked as private.
    Trevor Moderator
    #214731

    Thanks for that. You have two choices. If you are unlikely to changing the options very often, you can change the population of the field in the form from Automatically to Manual. That way you can edit the labels, and also the order.

    If that will not work as the options may change a lot, then you would have to sue this filter to programmatically change them:

    https://searchandfilter.com/documentation/action-filter-reference/#filter-input-object

    Andrew Turner
    #214739

    Thank you, I’m using the Number Range option for the distance drop-down and that doesn’t have a manual entry option, if I switch to Choice then it does have manual entry but then it isn’t a range. So I assume the only way for this to work would be using the filter?.

    I’ve looked at the full example here:https://gist.github.com/rmorse/7b59b45a14b1ca179868

    I understand some PHP but this a little advanced for me, would changing the following postfix line work?:

    //add/override prefix & postfix to the field
    $input_object[‘prefix’] = “Prefix”;
    $input_object[‘postfix’] = “miles”;

    Trevor Moderator
    #214753

    An alternative is to not use the PostFix option in the form, but add it using that filter to the label, not using the postfix code.

    Andrew Turner
    #214821

    Yes that’s what I’m trying to work out how to do.

    Andrew Turner
    #214862

    Any further help would be much appreciated.

    Trevor Moderator
    #214907

    I would imagine the PHP would be something like:

    function add_miles_to_filter_labels($input_object, $sfid) {
      if(($input_object['name']!='_sfm_colours') {
        return $input_object;
      }
      foreach($input_object['options'] as $option) }
        $option->label .= " miles";
      }
      return $input_object;
    }
    add_filter('sf_input_object_pre', 'add_miles_to_filter_labels', 10, 2);

    where you change $sfid to the actual ID of the form AND
    where you change the string/name _sfm_colours to whatever the data_sf_field_name actually is, for example, see here:

    https://www.screencast.com/t/wlh2lKrVDj4

    Andrew Turner
    #214925

    ok this is what I have so far:

    function add_miles_to_filter_labels($input_object, $2116) {
      if(($input_object['name']!='_sfm_distance[]') {
        return $input_object;
      }
      foreach($input_object['options'] as $option) }
        $option->label .= " miles";
      }
      return $input_object;
    }
    add_filter('sf_input_object_pre', 'add_miles_to_filter_labels', 10, 2);

    I’ve tried with and without the $ sign in front of the id, but I still get a parse error on the site.

Viewing 10 posts - 1 through 10 (of 24 total)

The topic ‘Customize Value Postfix’ is closed to new replies.