You are here

function location_cck_field_load in Location 7.5

Same name and namespace in other branches
  1. 7.3 contrib/location_cck/location_cck.module \location_cck_field_load()

Implement hook_field_load().

File

contrib/location_cck/location_cck.module, line 226
Defines location field type.

Code

function location_cck_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
  if ($entity_type == 'node') {
    foreach ($entities as $id => $entity) {
      foreach ($items[$id] as $delta => $item) {
        $location = array();

        // Load the location if it exists.
        // If we are previewing a new node it will not.
        if (!empty($item['lid'])) {
          $location = location_load_location($item['lid']);
        }

        // Combine the item with the location loaded from the database.
        // This will allow $item to display in the case of previewing a node.
        $items[$id][$delta] = array_merge($location, $item);
      }
    }
  }
}