function rdf_preprocess_taxonomy_term in Drupal 10
Same name and namespace in other branches
- 8 core/modules/rdf/rdf.module \rdf_preprocess_taxonomy_term()
- 7 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 564 - Enables semantically enriched output for Drupal sites in the form of RDFa.
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,
],
];
}
}