function rdf_field_attach_view_alter

rdf_field_attach_view_alter(&$output, $context)

Implements hook_field_attach_view_alter().

File

modules/rdf/rdf.module, line 741
Enables semantically enriched output for Drupal sites in the form of RDFa.

Code

function rdf_field_attach_view_alter(&$output, $context) {
  // Append term mappings on displayed taxonomy links.
  foreach (element_children($output) as $field_name) {
    $element = &$output[$field_name];
    if ($element['#field_type'] == 'taxonomy_term_reference' && $element['#formatter'] == 'taxonomy_term_reference_link') {
      foreach ($element['#items'] as $delta => $item) {
        // This function is invoked during entity preview when taxonomy term
        // reference items might contain free-tagging terms that do not exist
        // yet and thus have no $item['taxonomy_term'].
        if (isset($item['taxonomy_term'])) {
          $term = $item['taxonomy_term'];
          if (!empty($term->rdf_mapping['rdftype'])) {
            $element[$delta]['#options']['attributes']['typeof'] = $term->rdf_mapping['rdftype'];
          }
          if (!empty($term->rdf_mapping['name']['predicates'])) {
            // A property attribute is used with an empty datatype attribute so
            // the term name is parsed as a plain literal in RDFa 1.0 and 1.1.
            $element[$delta]['#options']['attributes']['property'] = $term->rdf_mapping['name']['predicates'];
            $element[$delta]['#options']['attributes']['datatype'] = '';
          }
        }
      }
    }
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!rdf!rdf.module/function/rdf_field_attach_view_alter/7.x