Community Documentation

Adding microdata support to fields

Last updated May 18, 2012. Created by linclark on June 7, 2011.
Log in to edit this page.

Microdata can be placed in the HTML tags around fields so that the data can be easily extracted into a JSON object. Microdata is very specific about where microdata attributes should be placed for different HTML tags, so sometimes the field formatters need to place the microdata themselves.

In order to enable microdata output for your fields, you have to:

  1. Enable microdata configuration
    Let microdata module know whether your field has microdata integration and/or whether your field has any properties that have microdata integration. Microdata module will then add a form section to the field settings so the user can specify which microdata terms they want to use for the field.
  2. Place microdata attributes in field formatter
    Based on the user's specifications, a microdata attributes array will be attached to the entity. This array is nested by field name. Your field formatter is responsible for placing the field's microdata attributes in the HTML that the formatter returns.

Additionally, you may want to:

  1. Write automated tests for microdata
  2. These can ensure that your microdata output doesn't break when changes are made to the formatter code.

Page status

About this page

Drupal version
Drupal 7.x
Audience
Programmers
Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here