template_preprocess_rdf_metadata

template_preprocess_rdf_metadata(&$variables)

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 596
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();
    }
  }
}
doc_Drupal
2016-10-29 09:46:46
Comments
Leave a Comment

Please login to continue.