You are here

function getlocations_fields_field_load in Get Locations 7.2

Same name and namespace in other branches
  1. 7 modules/getlocations_fields/getlocations_fields.module \getlocations_fields_field_load()

Implements hook_field_load(). Define custom load behavior for this module's field types. http://api.drupal.org/api/drupal/modules--field--field.api.php/function/...

Parameters

$entity_type: The type of $entity.

$entities: Array of entities being loaded, keyed by entity ID.

$field: The field structure for the operation.

$instances: Array of instance structures for $field for each entity, keyed by entity ID.

$langcode: The language code associated with $items.

$items: Array of field values already loaded for the entities, keyed by entity ID. Store your changes in this parameter (passed by reference).

$age: FIELD_LOAD_CURRENT to load the most recent revision for all fields, or FIELD_LOAD_REVISION to load the version indicated by each entity.

File

modules/getlocations_fields/getlocations_fields.module, line 388
getlocations_fields.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_fields_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
  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['glid'])) {
        $location = getlocations_fields_load_location($item['glid']);
      }

      // 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);
    }
  }
}