rdf_preprocess_taxonomy_term

rdf_preprocess_taxonomy_term(&$variables)

Implements hook_preprocess_HOOK() for taxonomy term templates.

File

core/modules/rdf/rdf.module, line 544
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'] = $term->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 = array(
      'property' => $name_field_mapping['properties'],
      'content' => $term->getName(),
    );
    $variables['title_suffix']['taxonomy_term_rdfa'] = array(
      '#theme' => 'rdf_metadata',
      '#metadata' => array($name_attributes),
    );
  }
}
doc_Drupal
2016-10-29 09:36:33
Comments
Leave a Comment

Please login to continue.