jquerydrupaldrupal-7viewdrupal-exposed-filter

Change the BEF slider field min/max value based on resultant nodes MAX MIN value


I have a Drupal view configured for showing services list with their prices and some other fields. I am using BEF module to filter the list of services on the front-end. Price field is using the jQuery Slider for filter data. Now i want to set the MINIMUM and MAXIMUM limit of slider based on MAX price node and MIN price node in the list.

I have tried hook_better_exposed_filters_settings_alter(&$settings) to change the BEF field settings but is no longer working in the latest update. Any one who achieved this please help!

Thanks in advance.

EDIT: Never mind if the solution leads me to change in BEF module file.


Solution

  • BEF module add these options as javascript options, so you can use hook_js_alter() to override it.

    /**
     * Implements hook_js_alter().
     */
    function MODULE_js_alter(&$javascript) {
      $settings = $javascript['settings']['data'];
    
      foreach ($settings as $key => $value) {
        if (isset($settings[$key]['better_exposed_filters']['slider_options']['commerce_price_amount']['max'])) {
          $settings[$key]['better_exposed_filters']['slider_options']['commerce_price_amount']['max'] = 1000;
        }
      }
    
      $javascript['settings']['data'] = $settings;
    }