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 Number Ranges Min-Max values

Tagged: 

Viewing 10 posts - 1 through 10 (of 15 total)
  • Nick Sotiriadis
    #257902

    Hello, I am opening a separate thread because I think this requires special attention.

    In all number ranges, either single or from/to fields the following options should be available:

    – Custom sets of values… eg define your own min/max values that are step independent. Imagine the following scenario:

    Min/Max
    0-500
    500-1000
    1000-5000
    5000-50000
    50000-100000
    etc

    – On top of this feature, it would be a good idea to be able to have a checkbox of some sort that does not restrict you to either a min or a max value. Based on the example I set previously.

    Min/Max

    50000-100000
    100000+ (No max)

    NS

    Trevor Moderator
    #257981
    Nick Sotiriadis
    #258012

    Awesome! And awesome support! Thanks Trevor!

    Trevor Moderator
    #258020

    Hi Nick. Do let me know if you get it working, and maybe you might be able to share your code?

    Nick Sotiriadis
    #258031

    Yes, I will try to have a look at it tomorrow and report back. Busy days…

    Nick Sotiriadis
    #258119

    So, here is my code, don’t know how you want to make use for it, but here it is in case it helps someone!

    First of all, I just set a couple of values in the admin, 0-100 – it makes no difference since I am unsetting the initial options anyway:

    function change_car_engine_size($input_object, $sfid) {
    		if($input_object['name']=='_sfm_car_engine_size') {
    			unset($input_object['options']);
    			$input_object['options']=array();
    			$arr = ['0','100','200','300','400', '500', '600', '700', '800', '900', '1000','2500','3000','3500','4000'];
    			foreach ($arr as $value) {
    				$new_option = new StdClass();
    				$new_option->value = $value;
    				$new_option->label = number_format($value, 0, ',', '.');
    				array_push($input_object['options'], $new_option);
    			}
    
    		}
    	return $input_object;
    }
    add_filter('sf_input_object_pre', 'change_car_engine_size', 10, 2);
    Nick Sotiriadis
    #258123

    …New question… I have no idea how to initially pre-select the last biggest value for tha max input option?

    Trevor Moderator
    #258132

    Pre-select is not currently available, I am sorry. Thanks for sharing the code.

    Nick Sotiriadis
    #258136

    Actually you can – sorry to prove you wrong!- just found it by examining the $input_object;

    I defined in the function:

    $input_object['default_max']=4000;
    $input_object['default_max_formatted']=4000;
    Trevor Moderator
    #258138

    Ah, but does it actually filter the results to that range?

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

The forum ‘Search & Filter Pro’ is closed to new topics and replies.