You are here

function template_preprocess_rdf_metadata in Drupal 8

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

Prepares variables for RDF metadata templates.

Default template: rdf-metadata.html.twig.

Sometimes it is useful to export data which is not semantically present in the HTML output. For example, a hierarchy of comments is visible for a human but not for machines because this hierarchy is not present in the DOM tree. We can express it in RDFa via empty <span> tags. These aren't visible and give machines extra information about the content and its structure.

Parameters

array $variables: An associative array containing:

  • metadata: An array of attribute arrays. Each item in the array corresponds to its own set of attributes, and therefore, needs its own element.

File

core/modules/rdf/rdf.module, line 615
Enables semantically enriched output for Drupal sites in the form of RDFa.

Code

function template_preprocess_rdf_metadata(&$variables) {
  foreach ($variables['metadata'] as $key => $attributes) {
    if (!is_null($attributes)) {
      $variables['metadata'][$key] = new Attribute($attributes);
    }
    else {
      $variables['metadata'][$key] = new Attribute();
    }
  }
}