You are here

function rdf_preprocess_taxonomy_term in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/rdf/rdf.module \rdf_preprocess_taxonomy_term()

Implements hook_preprocess_HOOK() for taxonomy term templates.

File

core/modules/rdf/rdf.module, line 540
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,
      ),
    );
  }
}