You are here

function metatags_quick_entity_load in Meta tags quick 7

Implements hook_entity_load.

Add html meta on entity load.

See also

http://api.drupal.org/api/drupal/modules--system--system.api.php/functio...

File

./metatags_quick.module, line 78

Code

function metatags_quick_entity_load($entities, $type) {
  $fields = drupal_static(__FUNCTION__);
  $type_info = entity_get_info($type);
  if (empty($type_info['fieldable'])) {
    return;
  }
  _metatags_quick_fieldable($type);

  // Find the meta tag fields to iterate over.
  if (!isset($fields[$type])) {
    $fields[$type] = array();
    $bundles = field_info_instances($type);
    if (empty($bundles)) {
      return;
    }
    foreach ($bundles as $bundle => $bundle_field_instances) {
      foreach ($bundle_field_instances as $field_name => $field) {
        $info = field_info_field_by_id($field['field_id']);
        if ($info['type'] == 'metatags_quick') {
          $fields[$type][] = $field_name;
        }
      }
    }
  }
  foreach ($entities as $entity) {
    foreach ($fields[$type] as $key) {
      if ($items = field_get_items($type, $entity, $key)) {
        foreach ($items as $item) {
          _metatags_quick_add_head(array(
            'name' => $item['meta_name'],
            'content' => $item['metatags_quick'],
            'entity' => $entity,
            'type' => $type,
          ));
        }
      }
    }
  }
}