function rdf_field_attach_view_alter
Implements hook_field_attach_view_alter().
File
-
modules/
rdf/ rdf.module, line 741
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'] = '';
}
}
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.