Contents

What is Microdata?

Microdata is a way of adding contextual information to your website and its contents, allowing search engines to better understand the information you provide them with.

Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose 'natural language' queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.

Microdata can be used to explain just about anything you would ever want to explain, and there are more 'schemas' being added on a regular basis. There are several vocabularies in existence, however at present the system favoured by search engines is that of schema.org.
To understand how search engines use the microdata information take a look at this short video.

How do I use Microdata?

Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.As of Joomla! there is a library within Joomla! which allows developers to pull in microdata without needing to format it correctly. The following resources are available by the author of the microdata library introducing the library and how to use it:

the microdata in a tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.

JMicrodata::htmlMeta($content,$property,$scope='',$inverse=false);

Return:

<meta $property$scope content='$content'>

the microdata in a <meta> tag with content for machines.

$microdata= JMicrodata($type='',$flag=true);

Create a new instance of the JMicrodata class and setup the current Type, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to Thing Type if the Type isn't available or given.

$microdata->enable($flag=true);

Enable or Disable HTML Microdata semantics output.

$microdata->isEnabled();

Return true if Microdata semantics HTML output are enabled.

$microdata->setType($type);

Set a new Schema.org Type, there is also a $microdata->getType() function to retrieve the current Type.

$microdata->property($name);

Setup the Property if available in the current Type Scope, there is also a $microdata->getProperty() function to retrieve the current Property.

$microdata->content($value,$machineValue=null);

Setup a Text value or Content value for the Microdata, there is also a $microdata->getContent() function to retrieve the current Text value.

$microdata->fallback($type,$property);

Setup a Fallback Type and Property, there are also the $microdata->getFallbackType() and $microdata->getFallbackProperty() to retrieve the Fallback Type and Fallback Property. Fallback to Thing Type if the Type isn't available, Fallback to null the Property if isn't available.

$microdata->displayScope();

Return:

itemscope itemtype="http://schema.org/$scope

the HTML with the Scope of the current Type, must be inserted inside a tag element.

$microdata->display($displayType='',$emptyOutput=false);

Return the Microdata HTML, if the Property isn't available it checks for a Fallback, otherwise return .

There are 4 types of $displayType:

inline

span

html

meta

This method contains the HTML Microdata display logic, If you specify the $displayType param, the Microdata will be returned the way you specified and expect — to, Otherwise if the $displayType param is empty it will be processed by the display() method and returned the HTML in the right way, with the expected Property Type (example of expectedTypes = URL, Text, Person ...)

— What happens if you call display($displayType = 'meta') ?
The returned HTML will be inside a <meta> HTML tag.

— What happend if you call display()?
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.