Computed field can use all cck fields without problems, but cannot reach the values at node->location['latitude'] or node->location[0]['latitude'] at all.

Any idea why this is so?

Comments

bdragon’s picture

Err, because latitude and longitude are filled in quite late in the process?

farald’s picture

Hmm. I thought so too.
May I somehow control when the location fields are processed, or is it fixed to be last?
Location is already lighter than computed field in my 'fields' list (edit nodetype 'page'), and so I am clueless.

I need this to perform some quite heavy proximity analysis based on the node's location, which cannot be done on node load or template, due to database performance issues.

I am grateful for any suggestions, as I already have chewed on this for a while:)

bdragon’s picture

Well, I suppose you could call _location_geo_logic() yourself...

farald’s picture

Aha!

function _location_geo_logic(&$location, $changed, $filled, $inhibit_geocode = FALSE)

Is this some kind of holder for the lat/lon being edited?
if yes, could you show me an example on how to retrieve the lat/lon out of it?

(I am using location with no other values enabled than lat/lon.)

EDIT:

By the way, I stumbled upon this:

http://drupal.org/node/279015#comment-1126783
Will this hack to location.module fix anything, or just make things worse? :)

farald’s picture

Forget the last one, tried it, and it didn't solve my problem.

Could somebody be kind and tell the noob (me) how to retrieve the latitude and longitude from _location_geo_logic() as mentioned in #3?

I'd be uttermost grateful! :)

farald’s picture

Status: Active » Fixed

Finally!

I saved the whole $node query to the database, and found out that location values is indeed not saved in $node->location[0][latitude]. BUT, the new lat/lon are stored in following:

$node->locations[0][locpick][user_latitude];
$node->locations[0][locpick][user_longitude];

So, to manipulate the locations from computed field, use these:)
However, I do not know what other location fields are called. To find out, just put

<?php
$node_field[0]['value'] = var_export($node, TRUE);
?>

in your custom field.
Let it save to the db as a 'text' type, save a node, then go to phpmyadmin and inspect the array.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.