1

After looking at the location module. I couldn't find any way to override the 'search_distance' parameter by creating a custom Form.

dose anyone know how to override this variable by using a custom module? .

I do have a map that is already searching proximity by zip code. it uses php code to determine the latitude, longitude.

I want to add the 'distance' selectbox next to the zipcode and filter it by (25 miles, 50 miles, 100 miles) like that.

Please note: the below Form for filtering is written in a custom module. so I'm looking for php code.

proximity search by zipcode

2 Answers 2

0

I haven't had much experience with Location module. This feature is supported out of the box with Openlayers module. I would recommend checking out that module.

I have done a similar sort of thing for one of my clients. I had to hide the distance fields as they didn't want that. If you view source you can see those fields in HTML.

http://biopetonline.com.au/stores

1
  • Thanks @ashish. I was able to solve this by overriding-views-handler .there is a method (query()) in 'extend location_views_handler_filter_proximity' class in location module. that's where all the query calls happens for distance based calculations. just added the logic in my custom module and that solved the issue
    – danuddara
    Mar 2, 2017 at 3:27
0

Found a solution for this. you need to override the query() method in 'location_views_handler_filter_proximity' handler class for your view. This link will help you to understand to override the view handler. you can extend the old class with the custom class that you want to override.

I can see the variable get updated with what i wanted now. below is a sample code that you would use for this kind of a override.

    class Yourcustom_class extend location_views_handler_filter_proximity{
    public function query() {

 if(!empty(filter_xss($_REQUEST['dist'])))
            {
                $distquery=  filter_xss($_REQUEST['dist']);
                $this->value['search_distance'] = $distquery;
            }

      }

}

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.