theme_rdf_metadata

Versions
7
theme_rdf_metadata($variables)

Outputs a series of empty spans for exporting RDF metadata in RDFa.

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 hiearchy 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.

See also

rdf_process()

Parameters

$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.

Return value

A string of HTML containing markup that can be understood by RDFa parsers.

Related topics

Code

modules/rdf/rdf.module, line 668

<?php
function theme_rdf_metadata($variables) {
  $output = '';
  foreach ($variables['metadata'] as $attributes) {
    // Add a class, so developers viewing html source have a reference for why
    // there are empty spans in the document. Also can be used to set a CSS
    // display:none rule in a theme where empty spans affect display.
    $attributes['class'][] = 'rdf-meta';
    // XHTML+RDFa doctype allows either <span></span> or <span />, but for
    // maximum browser compatibility, W3C recommends the former when serving
    // pages using the text/html media type: http://www.w3.org/TR/xhtml1/#C_3.
    $output .= '<span' . drupal_attributes($attributes) . '></span>';
  }
  return $output;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.