I'm trying to see if there is a way to default the views proximity filter to input zero for proximity values when the filter is empty, so we can sort the data using a different field by default.

What I've got currently

A view that lists location nodes (that use the geolocation module) using the 'Content' show/render. The format settings is set to force fields, so we can set the proximity field information. The view has an exposed proximity filter using Google Geocoding, and the proximity field is set to center off of this proximity filter.

Additionally, the view is sorted first by proximity, and second by title.

Proximity filtering works

When users type in an address, the view sorts by proximity, and works as expected.

Desired Outcome

A user visits the page, the locations are sorted by title alphabetically, then if an address is entered into the filter the locations are sorted by proximity first and then title second.

What happens now

When the page is initially loaded and nothing is entered into the filter the proximity the locations appear to be sorted in an arbitrary/random order. If you display the proximity, it's clear it's still sorting by proximity, but I don't know based on what.

Are there any suggestions to configure this differently? Are there hooks I could access to override the proximity value to zero if the filter is empty?

I've Googled a fair bit, and tried searching the issue queue, but haven't been able to find any direction that way so far. So thanks in advance to anyone that is able to offer any help or direction.

  • I'm voting to close this question as off-topic because it should better be posted as support request in the drupal.org/project/geofield_proximity_filter issue queue, not here.
    – leymannx
    Jun 21, 2019 at 23:55
  • It's actually the drupal.org/project/geolocation module. I've posted it in that module's issue queue as a support request. I'm confused by the 'off-topic' aspect though. Is it simply because it can be asked in another forum? Or is this site focused on a specific set of features/modules that this doesn't meet?
    – Chris Budy
    Jun 22, 2019 at 1:16
  • It's you are basically asking about (probably missing) documentation or module-specific hooks (have you read the module yourself?), that's why I considered it off-topic. Asking for off-site resources is considered off-topic on Drupal Answers. Your issue may potentially also turn out as a bug, and that should definitely be handled in the module's issue queue, not here.
    – leymannx
    Jun 22, 2019 at 8:01
  • Isn't there an option in your Proximity filter to enter the Miles/Kilometers? Simply set it to 0, it will be used when the filter is loaded. Then when users change it the results will react. Keep the proximity sort. If it's an address simply enter the address for the center point in the filter settings.
    – prkos
    Jun 22, 2019 at 11:03


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.