function rdf_preprocess_taxonomy_term
Same name in other branches
- 7.x modules/rdf/rdf.module \rdf_preprocess_taxonomy_term()
- 9 core/modules/rdf/rdf.module \rdf_preprocess_taxonomy_term()
Implements hook_preprocess_HOOK() for taxonomy term templates.
File
-
core/
modules/ rdf/ rdf.module, line 563
Code
function rdf_preprocess_taxonomy_term(&$variables) {
// Adds RDFa markup to the taxonomy term container.
// The @about attribute specifies the URI of the resource described within
// the HTML element, while the @typeof attribute indicates its RDF type
// (e.g., schema:Thing, skos:Concept, and so on).
$term = $variables['term'];
$mapping = rdf_get_mapping('taxonomy_term', $term->bundle());
$bundle_mapping = $mapping->getPreparedBundleMapping();
$variables['attributes']['about'] = $variables['url'];
$variables['attributes']['typeof'] = empty($bundle_mapping['types']) ? NULL : $bundle_mapping['types'];
// Add RDFa markup for the taxonomy term name as metadata, if present.
$name_field_mapping = $mapping->getPreparedFieldMapping('name');
if (!empty($name_field_mapping) && !empty($name_field_mapping['properties'])) {
$name_attributes = [
'property' => $name_field_mapping['properties'],
'content' => $term->getName(),
];
$variables['title_suffix']['taxonomy_term_rdfa'] = [
'#theme' => 'rdf_metadata',
'#metadata' => [
$name_attributes,
],
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.