0

I'm working on a D7 project where I need to pass a latitude/longitude value from a Location field (acquired from geolocating during import) to a Computed field.

I found the following code in the computed field documentation, which loads the field into the computed field:

$field_info = array_pop(field_get_items($entity_type, $entity, 'field_geo'));

However, if I do a dpm($field_info); all location information is there, EXCEPT lat/long.

Any way around this? Thanks!

0

I think I was assuming locations are geolocated on edit/changes and that's saved to DB, which appears to not be the case. At any rate, I was able to use the location ID from $field_info to load the location, which then has the lat/long data I need:

$loc = location_load_location($field_info['lid']);
$longitude = $loc['longitude'];
$latitude = $loc['latitude'];

That was annoying...

| improve this answer | |
  • My content has field_latitude and field_longitude. How would I grab those in the PHP field of the location filter? Or at least, how can I dpm() SOMETHING in there to help me find it? there's no $view, $vars, $variables, etc. And there's certainly no documentation on getting fields from your nodes in there. – ProGrammar Jun 23 '17 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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