function 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),
    );
  }
}

© 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/core!modules!rdf!rdf.module/function/rdf_preprocess_taxonomy_term/8.1.x