Access of Location data for a Computed Field

Events happening in the community are now at Drupal community events on www.drupal.org.
husainsn's picture

Hello
I have a node type with location data. I want to access latitude and longitude data to calculate Sunrise time in a computed field on the same node - but no success. The code in computed field is:

$lat = $node->$location[latitude];
$long = $node->$location[longitude];
$node_field[0]['value'] = date_sunrise(time(), SUNFUNCS_RET_STRING, $lat, $long, 90, -5);

I can access latitude data $location[latitude] in the theme override, and can calculate sunrise. I want to use the computed field in a View.

Any help will be appreciated.

Comments

Your code snippet seems

Grayside's picture

Your code snippet seems wrong.

Assuming location is an array held in your node object, you would reference it as $node->location['latitude'] and $node->location['longitude'].

I think you might find some

nadavoid's picture

I think you might find some good tips in this blog post. http://www.coalmarch.com/coalmarch-blog/20090607268/building-a-lunar-cal...

Thanks

husainsn's picture

Tried but no success

Did you found a solution ?

bneel's picture

Did you found a solution ?

Not Yet

husainsn's picture

Hi bneel:
It did not have my full time attention on the problem. I run a charity and was trying out ideas for web new page. Anyway I have been abroad for the last 6 weeks and I am replying you from Pakistan. I am a 70 year old retired engineer, and a self taught Drupalist (www.MuslimServ.com). As I perceive the problem has something to do with views as I want to show the the output in a view. I went over views but without success as yet. I thank you for replying me and letting me know possible solution.

Content Construction Kit (CCK)

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: