I'm using a Geolocation field in views to order results by distance. The module provides a special views proximity plugin/field, which can be used in the "sort" section of the view. This plugin/field has a "proximity setting" (lat/long) to define the center point for distance calculation. I got this far in views UI and this all works.
I now need to programmatically change that center point based on a custom logic derived from the current user, but I don't know which views hook to use to alter this field setting.
Tried, didn't work:
function MYMODULE_views_pre_view($view, $display_id, &$args) {
//my field's machine name is "field_geo"
$geoField = $view->display_handler->getHandler('field', 'field_geo_proximity');
//print_r($geofield) is empty
//suffix "_proximity" seems to be added by geolocation module, but does not work either
$geoFieldProximity = $view->display_handler->getHandler('field', 'field_geo_proximity');
//print_r($geofieldProximity) is empty
}
I've got two questions:
- Is
pre_view
the correct hook to alter the field setting? (If not, which hook should I use instead?) - How to I get/set those field settings?
I thought I need to use$view->display_handler->getHandler()
but didn't get any results.