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 › Customize Value Postfix
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.
Are you able to send me a live link/URL to your search page so I can take a look?
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
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”;
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.
Yes that’s what I’m trying to work out how to do.
Any further help would be much appreciated.
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:
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.
The topic ‘Customize Value Postfix’ 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