<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=P.Alex</id>
	<title>Joomla! Documentation - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=P.Alex"/>
	<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/Special:Contributions/P.Alex"/>
	<updated>2026-07-09T23:46:19Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Using_own_library_in_your_extensions&amp;diff=122256</id>
		<title>Using own library in your extensions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Using_own_library_in_your_extensions&amp;diff=122256"/>
		<updated>2014-07-15T08:15:46Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{version/tutor|2.5,3.1}}&lt;br /&gt;
There are several approaches how to register your own library with Joomla&#039;s autoloader and then use it in your extension. All these approaches are based on the &amp;lt;code&amp;gt;JLoader&amp;lt;/code&amp;gt; class. For this tutorial we consider that your library is located in the &#039;&#039;&#039;/libraries/mylib&#039;&#039;&#039; folder.&lt;br /&gt;
&lt;br /&gt;
== Discovering Classes ==&lt;br /&gt;
Classes in a folder that follow a naming convention can be registered collectively with JLoader&#039;s [http://api.joomla.org/cms-2.5/classes/JLoader.html#method_discover discover()] method. The discover method looks at the file names in a folder and registers classes based on those names. Additional arguments can be used to update the class register and recurse into sub-folders.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Register all files in the /libraries/mylib folder as classes with a name like:  MyLib&amp;lt;Filename&amp;gt;&lt;br /&gt;
JLoader::discover(&#039;Mylib&#039;, JPATH_LIBRARIES . &#039;/mylib&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see this method is working if you follow special naming convention:&lt;br /&gt;
* &amp;lt;code&amp;gt;/mylib/user.php&amp;lt;/code&amp;gt; will be equal to &amp;lt;code&amp;gt;MylibUser&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;/mylib/userhelper.php&amp;lt;/code&amp;gt; will be equal to &amp;lt;code&amp;gt;MylibUserHelper&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The Prefix Loader ==&lt;br /&gt;
Since Joomla Platform 12.1 (Joomla! CMS 3+), there is the ability to register where the auto-loader will look based on a class prefix (previously only the &amp;quot;J&amp;quot; prefix was supported, bound to the /libraries/joomla folder). This is done with the [http://api.joomla.org/Joomla-Platform/JLoader.html#registerPrefix registerPrefix()] method and allows for several scenarios:&lt;br /&gt;
&lt;br /&gt;
* A developer can register the prefix of custom classes, and a root path to allow the auto-loader to find them.&lt;br /&gt;
* A developer can register an extra path for an existing prefix (for example, this allows the Joomla CMS to have custom libraries but still using the &amp;quot;J&amp;quot; prefix).&lt;br /&gt;
* A developer can register a force override for a prefix. This could be used to completely override the core classes with a custom replacement.&lt;br /&gt;
&lt;br /&gt;
=== Convention ===&lt;br /&gt;
The class name must be in camel case and each segment of the name will represent a folder path where the last segment of the name is the name of the class file. If there is only one part to the class name, the auto-loader will look for the file in a folder of the same name. Folder names must be in lower case.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples:&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;PrefixUserModel&amp;lt;/code&amp;gt; class should be located in &amp;lt;code&amp;gt;PATH_TO_PREFIX/user/model.php&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;PrefixUser&amp;lt;/code&amp;gt; class should be located in &amp;lt;code&amp;gt;PATH_TO_PREFIX/user/user.php&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Our scenario examples:&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;MylibUserHelper&amp;lt;/code&amp;gt; class should be located in &amp;lt;code&amp;gt;/libraries/mylib/user/helper.php&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;MylibUser&amp;lt;/code&amp;gt; class should be located in &amp;lt;code&amp;gt;/libraries/mylib/user/user.php&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is no limit to the depth to which the auto-loader will search, providing it forms a valid path based on the camel case natural of the class name. Note that while acronyms and names such as HTML, XML and MySQL have a standard presention in text, such terms should observe camel case rules programmatically (&amp;quot;HTML&amp;quot; becomes &amp;quot;Html&amp;quot;, &amp;quot;XML&amp;quot; becomes &amp;quot;Xml&amp;quot; and so on).&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Tell the auto-loader to look for classes starting with &amp;quot;Mylib&amp;quot; in a specific folder.&lt;br /&gt;
JLoader::registerPrefix(&#039;Mylib&#039;, JPATH_LIBRARIES . &#039;/mylib&#039;);&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Tell the auto-loader to also look in the /libraries/cms folder for &amp;quot;J&amp;quot; prefixed classes.&lt;br /&gt;
JLoader::registerPrefix(&#039;J&#039;, JPATH_PLATFORM . &#039;/cms&#039;);&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Tell the auto-loader to reset the &amp;quot;J&amp;quot; prefix and point it to a custom fork of the platform.&lt;br /&gt;
JLoader::registerPrefix(&#039;J&#039;, &#039;/my/platform/fork&#039;, true);&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Note on registerPrefix ===&lt;br /&gt;
For Joomla CMS 2.5, prefix cannot start with the same letter, otherwise the first matched will be tried to load. For example if we register prefix &#039;JM&#039;, as &#039;J&#039; prefix exists so JLoader will find &#039;J&#039; prefix. When it tries to search for class in the registered path of &#039;J&#039;, no class found.&lt;br /&gt;
  &lt;br /&gt;
== Namespace Loader ==&lt;br /&gt;
As of Joomla CMS v3.1.2, the core autoloader has had support for autoloading [http://www.php-fig.org/psr/psr-0/ PSR-0] style namespaced libraries. (You can read up on PHP namespaces [http://php.net/manual/en/language.namespaces.php here]. If you only support Joomla on PHP 5.3+ (which you do if you only support Joomla CMS v3.x or greater), then you can utilize code that uses native PHP namespaces. In accordance with PSR-0 rules, the directory and file casing must match that of the PHP namespace and class.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;MyLib\User\UserHelper&amp;lt;/code&amp;gt; class must be located in &amp;lt;code&amp;gt;LIBROOT/src/MyLib/User/UserHelper.php&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Tell the auto-loader to look for namespaced classes starting with MyLib in the LIBROOT/src directory&lt;br /&gt;
JLoader::registerNamespace(&#039;MyLib&#039;, LIBROOT . &#039;/src&#039;);&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Accessing library from any place ==&lt;br /&gt;
To access our library from any place of an application we should create a system plugin which will register our library with the JLoader. This plugin should fire on &amp;lt;code&amp;gt;onAfterInitialise&amp;lt;/code&amp;gt; event:&lt;br /&gt;
&lt;br /&gt;
=== Manifest file ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension version=&amp;quot;3.0&amp;quot; type=&amp;quot;plugin&amp;quot; group=&amp;quot;system&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;name&amp;gt;System - Mylib&amp;lt;/name&amp;gt;&lt;br /&gt;
    &amp;lt;author&amp;gt;Joomla! Project&amp;lt;/author&amp;gt;&lt;br /&gt;
    &amp;lt;creationDate&amp;gt;March 2013&amp;lt;/creationDate&amp;gt;&lt;br /&gt;
    &amp;lt;copyright&amp;gt;Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.&amp;lt;/copyright&amp;gt;&lt;br /&gt;
    &amp;lt;license&amp;gt;GNU General Public License version 2 or later.&amp;lt;/license&amp;gt;&lt;br /&gt;
    &amp;lt;authorEmail&amp;gt;admin@joomla.org&amp;lt;/authorEmail&amp;gt;&lt;br /&gt;
    &amp;lt;authorUrl&amp;gt;www.joomla.org&amp;lt;/authorUrl&amp;gt;&lt;br /&gt;
    &amp;lt;version&amp;gt;1.0.0&amp;lt;/version&amp;gt;&lt;br /&gt;
    &amp;lt;description&amp;gt;Simple example plugin to register custom library.&amp;lt;/description&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;files&amp;gt;&lt;br /&gt;
        &amp;lt;filename plugin=&amp;quot;mylib&amp;quot;&amp;gt;mylib.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
        &amp;lt;filename&amp;gt;index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
    &amp;lt;/files&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Plugin file ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.&lt;br /&gt;
 * @license     GNU General Public License version 2 or later.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Mylib plugin class.&lt;br /&gt;
 *&lt;br /&gt;
 * @package     Joomla.plugin&lt;br /&gt;
 * @subpackage  System.mylib&lt;br /&gt;
 */&lt;br /&gt;
class plgSystemMylib extends JPlugin&lt;br /&gt;
{&lt;br /&gt;
    /**&lt;br /&gt;
     * Method to register custom library.&lt;br /&gt;
     *&lt;br /&gt;
     * return  void&lt;br /&gt;
     */&lt;br /&gt;
    public function onAfterInitialise()&lt;br /&gt;
    {&lt;br /&gt;
        JLoader::registerPrefix(&#039;Mylib&#039;, JPATH_LIBRARIES . &#039;/mylib&#039;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you will be able to call classes from your library (located in /libraries/mylib) from any component, module or plugin.&lt;br /&gt;
[[Category:Development]][[Category:Tutorials]]&lt;br /&gt;
[[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117279</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117279"/>
		<updated>2014-04-07T18:49:00Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: /* How do I use the JMicrodata library? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly.&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a library to implement and output http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The library was designed with this goals in mind:&lt;br /&gt;
# Having the &#039;&#039;&#039;possibility to switch the Microdata Type dynamically&#039;&#039;&#039;, you just change the Type (there are 558 different available types).&lt;br /&gt;
# &#039;&#039;&#039;Display validated semantics&#039;&#039;&#039;, the library takes care to display data correctly.&lt;br /&gt;
# &#039;&#039;&#039;Enable/disable the microdata&#039;&#039;&#039; semantics.&lt;br /&gt;
# &#039;&#039;&#039;Fallbacks&#039;&#039;&#039;, you should never lose any meaningful semantic.&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;, that file was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And you want to add microdata semantics and you setup the current scope type as &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div &amp;lt;?php echo $microdata-&amp;gt;displayScope();?&amp;gt;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Alexandru Pruteanu&#039;)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Here is the article text...&#039;)-&amp;gt;property(&#039;articleBody&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div itemscope itemtype=&#039;https://schema.org/Article&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by&lt;br /&gt;
        &amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
            &amp;lt;span itemprop=&#039;name&#039;&amp;gt;Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
        &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;articleBody&#039;&amp;gt;Here is the article text...&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;articleBody&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$microdata = new JMicrodata(&#039;Product&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div &amp;lt;?php echo $microdata-&amp;gt;displayScope();?&amp;gt;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Alexandru Pruteanu&#039;)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Here is the article text...&#039;)-&amp;gt;property(&#039;articleBody&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
As you&#039;ve added a fallback &amp;lt;tt&amp;gt;-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)&amp;lt;/tt&amp;gt;, it will fallback to the &amp;lt;i&amp;gt;Person&amp;lt;/i&amp;gt; type, and you will not lose any meaningful semantic.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div itemscope itemtype=&#039;https://schema.org/Product&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by&lt;br /&gt;
        &amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
            &amp;lt;span itemprop=&#039;name&#039;&amp;gt;Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
        &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If you don&#039;t need all that microdata information, you just disable that feature by calling: &amp;lt;tt&amp;gt;$microdata-&amp;gt;enable(false);&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$microdata = new JMicrodata(&#039;Product&#039;);&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div &amp;lt;?php echo $microdata-&amp;gt;displayScope();?&amp;gt;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Alexandru Pruteanu&#039;)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Here is the article text...&#039;)-&amp;gt;property(&#039;articleBody&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlScope($scope);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlProperty($property);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlSpan($content, $property = &amp;quot;&amp;quot;, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlMeta($content, $property, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&amp;quot;$content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with the &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;, this method does not add the meta tag in the &amp;lt;head&amp;gt; section of the page.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata = JMicrodata($type = &amp;quot;&amp;quot;, $flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;enable($flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;isEnabled();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;setType($type);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;property($name);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;content($value, $machineValue = null);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;fallback($type, $property);&#039;&#039;&#039;&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;displayScope();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;display($displayType = &amp;quot;&amp;quot;, $emptyOutput = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &amp;quot;meta&amp;quot;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;&amp;quot;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117251</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117251"/>
		<updated>2014-04-07T17:03:41Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: /* How do I use the JMicrodata library? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly.&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a library to implement and output http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The library was designed with this goals in mind:&lt;br /&gt;
# Having the &#039;&#039;&#039;possibility to switch the Microdata Type dynamically&#039;&#039;&#039;, you just change the Type (there are 558 different available types).&lt;br /&gt;
# &#039;&#039;&#039;Display validated semantics&#039;&#039;&#039;, the library takes care to display data correctly.&lt;br /&gt;
# &#039;&#039;&#039;Enable/disable the microdata&#039;&#039;&#039; semantics.&lt;br /&gt;
# &#039;&#039;&#039;Fallbacks&#039;&#039;&#039;, you should never lose any meaningful semantic.&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;, that file was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And you want to add microdata semantics and you setup the current scope type as &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div &amp;lt;?php echo $microdata-&amp;gt;displayScope();?&amp;gt;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Alexandru Pruteanu&#039;)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Here is the article text...&#039;)-&amp;gt;property(&#039;articleBody&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div itemscope itemtype=&#039;https://schema.org/Article&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by&lt;br /&gt;
        &amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
            &amp;lt;span itemprop=&#039;name&#039;&amp;gt;Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
        &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;articleBody&#039;&amp;gt;Here is the article text...&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;articleBody&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$microdata = new JMicrodata(&#039;Product&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div &amp;lt;?php echo $microdata-&amp;gt;displayScope();?&amp;gt;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Alexandru Pruteanu&#039;)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Here is the article text...&#039;)-&amp;gt;property(&#039;articleBody&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
As you&#039;ve added a fallback &amp;lt;tt&amp;gt;-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)&amp;lt;/tt&amp;gt;, it will fallback to the &amp;lt;i&amp;gt;Person&amp;lt;/i&amp;gt; type, and you will not lose any meaningful semantic.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div itemscope itemtype=&#039;https://schema.org/Product&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by&lt;br /&gt;
        &amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
            &amp;lt;span itemprop=&#039;name&#039;&amp;gt;Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
        &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If you don&#039;t need all that microdata information, you just disable that feature by calling: &amp;lt;tt&amp;gt;$microdata-&amp;gt;enable(false);&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$microdata = new JMicrodata(&#039;Product&#039;);&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div &amp;lt;?php echo $microdata-&amp;gt;displayScope();?&amp;gt;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Alexandru Pruteanu&#039;)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Here is the article text...&#039;)-&amp;gt;property(&#039;articleBody&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;Written by Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlScope($scope);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlProperty($property);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlSpan($content, $property = &amp;quot;&amp;quot;, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlMeta($content, $property, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&amp;quot;$content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with the &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;, this method does not add the meta tag in the &amp;lt;head&amp;gt; section of the page.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata = JMicrodata($type = &amp;quot;&amp;quot;, $flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;enable($flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;isEnabled();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;setType($type);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;property($name);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;content($value, $machineValue = null);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;fallback($type, $property);&#039;&#039;&#039;&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;displayScope();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;display($displayType = &amp;quot;&amp;quot;, $emptyOutput = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &amp;quot;meta&amp;quot;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;&amp;quot;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117250</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117250"/>
		<updated>2014-04-07T16:54:47Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: /* How do I use the JMicrodata library? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly.&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a library to implement and output http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The library was designed with this goals in mind:&lt;br /&gt;
# Having the &#039;&#039;&#039;possibility to switch the Microdata Type dynamically&#039;&#039;&#039;, you just change the Type (there are 558 different available types).&lt;br /&gt;
# &#039;&#039;&#039;Display validated semantics&#039;&#039;&#039;, the library takes care to display data correctly.&lt;br /&gt;
# &#039;&#039;&#039;Enable/disable the microdata&#039;&#039;&#039; semantics.&lt;br /&gt;
# &#039;&#039;&#039;Fallbacks&#039;&#039;&#039;, you should never lose any meaningful semantic.&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;, that file was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And you want to add microdata semantics and you setup the current scope type as &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div &amp;lt;?php echo $microdata-&amp;gt;displayScope();?&amp;gt;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Alexandru Pruteanu&#039;)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Here is the article text...&#039;)-&amp;gt;property(&#039;articleBody&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div itemscope itemtype=&#039;https://schema.org/Article&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by&lt;br /&gt;
        &amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
            &amp;lt;span itemprop=&#039;name&#039;&amp;gt;Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
        &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;articleBody&#039;&amp;gt;Here is the article text...&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;articleBody&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$microdata = new JMicrodata(&#039;Product&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div &amp;lt;?php echo $microdata-&amp;gt;displayScope();?&amp;gt;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Alexandru Pruteanu&#039;)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Here is the article text...&#039;)-&amp;gt;property(&#039;articleBody&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Well it will fallback, so you will not lose any meaningful semantic:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div itemscope itemtype=&#039;https://schema.org/Product&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by&lt;br /&gt;
        &amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
            &amp;lt;span itemprop=&#039;name&#039;&amp;gt;Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
        &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If you don&#039;t need all that microdata information, you just disable that feature by calling &amp;lt;tt&amp;gt;$microdata-&amp;gt;enable(false);&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;Written by Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlScope($scope);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlProperty($property);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlSpan($content, $property = &amp;quot;&amp;quot;, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlMeta($content, $property, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&amp;quot;$content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with the &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;, this method does not add the meta tag in the &amp;lt;head&amp;gt; section of the page.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata = JMicrodata($type = &amp;quot;&amp;quot;, $flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;enable($flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;isEnabled();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;setType($type);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;property($name);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;content($value, $machineValue = null);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;fallback($type, $property);&#039;&#039;&#039;&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;displayScope();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;display($displayType = &amp;quot;&amp;quot;, $emptyOutput = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &amp;quot;meta&amp;quot;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;&amp;quot;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117249</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117249"/>
		<updated>2014-04-07T16:50:19Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: /* How do I use the JMicrodata library? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly.&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a library to implement and output http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The library was designed with this goals in mind:&lt;br /&gt;
# Having the &#039;&#039;&#039;possibility to switch the Microdata Type dynamically&#039;&#039;&#039;, you just change the Type (there are 558 different available types).&lt;br /&gt;
# &#039;&#039;&#039;Display validated semantics&#039;&#039;&#039;, the library takes care to display data correctly.&lt;br /&gt;
# &#039;&#039;&#039;Enable/disable the microdata&#039;&#039;&#039; semantics.&lt;br /&gt;
# &#039;&#039;&#039;Fallbacks&#039;&#039;&#039;, you should never lose any meaningful semantic.&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;, that file was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And you want to add microdata semantics and you setup the current scope type as &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div &amp;lt;?php echo $microdata-&amp;gt;displayScope();?&amp;gt;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Alexandru Pruteanu&#039;)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Here is the article text...&#039;)-&amp;gt;property(&#039;articleBody&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div itemscope itemtype=&#039;https://schema.org/Article&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by&lt;br /&gt;
        &amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
            &amp;lt;span itemprop=&#039;name&#039;&amp;gt;Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
        &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;articleBody&#039;&amp;gt;Here is the article text...&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;articleBody&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$microdata = new JMicrodata(&#039;Product&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div &amp;lt;?php echo $microdata-&amp;gt;displayScope();?&amp;gt;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Alexandru Pruteanu&#039;)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Here is the article text...&#039;)-&amp;gt;property(&#039;articleBody&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Well it will fallback, so you will not lose any meaningful semantic:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div itemscope itemtype=&#039;https://schema.org/Product&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by&lt;br /&gt;
        &amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
            &amp;lt;span itemprop=&#039;name&#039;&amp;gt;Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
        &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If you don&#039;t need all that microdata information, you just disable that feature by calling &amp;lt;code&amp;gt;$microdata-&amp;gt;enable(false);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;Written by Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlScope($scope);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlProperty($property);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlSpan($content, $property = &amp;quot;&amp;quot;, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlMeta($content, $property, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&amp;quot;$content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with the &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;, this method does not add the meta tag in the &amp;lt;head&amp;gt; section of the page.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata = JMicrodata($type = &amp;quot;&amp;quot;, $flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;enable($flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;isEnabled();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;setType($type);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;property($name);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;content($value, $machineValue = null);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;fallback($type, $property);&#039;&#039;&#039;&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;displayScope();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;display($displayType = &amp;quot;&amp;quot;, $emptyOutput = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &amp;quot;meta&amp;quot;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;&amp;quot;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117248</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117248"/>
		<updated>2014-04-07T16:49:47Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: /* How do I use the JMicrodata library? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly.&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a library to implement and output http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The library was designed with this goals in mind:&lt;br /&gt;
# Having the &#039;&#039;&#039;possibility to switch the Microdata Type dynamically&#039;&#039;&#039;, you just change the Type (there are 558 different available types).&lt;br /&gt;
# &#039;&#039;&#039;Display validated semantics&#039;&#039;&#039;, the library takes care to display data correctly.&lt;br /&gt;
# &#039;&#039;&#039;Enable/disable the microdata&#039;&#039;&#039; semantics.&lt;br /&gt;
# &#039;&#039;&#039;Fallbacks&#039;&#039;&#039;, you should never lose any meaningful semantic.&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;, that file was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And you want to add microdata semantics and you setup the current scope type as &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div &amp;lt;?php echo $microdata-&amp;gt;displayScope();?&amp;gt;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Alexandru Pruteanu&#039;)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Here is the article text...&#039;)-&amp;gt;property(&#039;articleBody&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div itemscope itemtype=&#039;https://schema.org/Article&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by&lt;br /&gt;
        &amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
            &amp;lt;span itemprop=&#039;name&#039;&amp;gt;Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
        &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;articleBody&#039;&amp;gt;Here is the article text...&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;articleBody&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$microdata = new JMicrodata(&#039;Product&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div &amp;lt;?php echo $microdata-&amp;gt;displayScope();?&amp;gt;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Alexandru Pruteanu&#039;)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Here is the article text...&#039;)-&amp;gt;property(&#039;articleBody&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Well it will fallback, so you will not lose any meaningful semantic:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div itemscope itemtype=&#039;https://schema.org/Product&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by&lt;br /&gt;
        &amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
            &amp;lt;span itemprop=&#039;name&#039;&amp;gt;Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
        &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If you don&#039;t need all that microdata information, you just disable that feature by calling &amp;lt;code&amp;gt;$microdata-&amp;gt;enable(false);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;Written by Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlScope($scope);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlProperty($property);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlSpan($content, $property = &amp;quot;&amp;quot;, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlMeta($content, $property, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&amp;quot;$content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with the &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;, this method does not add the meta tag in the &amp;lt;head&amp;gt; section of the page.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata = JMicrodata($type = &amp;quot;&amp;quot;, $flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;enable($flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;isEnabled();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;setType($type);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;property($name);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;content($value, $machineValue = null);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;fallback($type, $property);&#039;&#039;&#039;&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;displayScope();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;display($displayType = &amp;quot;&amp;quot;, $emptyOutput = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &amp;quot;meta&amp;quot;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;&amp;quot;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117247</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117247"/>
		<updated>2014-04-07T16:41:11Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: /* How do I use the JMicrodata library? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly.&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a library to implement and output http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The library was designed with this goals in mind:&lt;br /&gt;
# Having the &#039;&#039;&#039;possibility to switch the Microdata Type dynamically&#039;&#039;&#039;, you just change the Type (there are 558 different available types).&lt;br /&gt;
# &#039;&#039;&#039;Display validated semantics&#039;&#039;&#039;, the library takes care to display data correctly.&lt;br /&gt;
# &#039;&#039;&#039;Enable/disable the microdata&#039;&#039;&#039; semantics.&lt;br /&gt;
# &#039;&#039;&#039;Fallbacks&#039;&#039;&#039;, you should never lose any meaningful semantic.&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;, that file was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And you want to add microdata semantics and you setup the current scope type as &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div &amp;lt;?php echo $microdata-&amp;gt;displayScope();?&amp;gt;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Alexandru Pruteanu&#039;)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Here is the article text...&#039;)-&amp;gt;property(&#039;articleBody&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div itemscope itemtype=&#039;https://schema.org/Article&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by&lt;br /&gt;
        &amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
            &amp;lt;span itemprop=&#039;name&#039;&amp;gt;Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
        &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;articleBody&#039;&amp;gt;Here is the article text...&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;articleBody&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Product&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div &amp;lt;?php echo $microdata-&amp;gt;displayScope();?&amp;gt;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Alexandru Pruteanu&#039;)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Here is the article text...&#039;)-&amp;gt;property(&#039;articleBody&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Well it will fallback, so you will not lose any meaningful semantic:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div itemscope itemtype=&#039;https://schema.org/Thing&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by&lt;br /&gt;
        &amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
            &amp;lt;span itemprop=&#039;name&#039;&amp;gt;Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
        &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;Written by Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlScope($scope);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlProperty($property);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlSpan($content, $property = &amp;quot;&amp;quot;, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlMeta($content, $property, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&amp;quot;$content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with the &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;, this method does not add the meta tag in the &amp;lt;head&amp;gt; section of the page.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata = JMicrodata($type = &amp;quot;&amp;quot;, $flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;enable($flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;isEnabled();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;setType($type);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;property($name);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;content($value, $machineValue = null);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;fallback($type, $property);&#039;&#039;&#039;&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;displayScope();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;display($displayType = &amp;quot;&amp;quot;, $emptyOutput = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &amp;quot;meta&amp;quot;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;&amp;quot;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117246</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117246"/>
		<updated>2014-04-07T16:31:40Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: /* How do I use the JMicrodata library? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly.&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a library to implement and output http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The library was designed with this goals in mind:&lt;br /&gt;
# Having the &#039;&#039;&#039;possibility to switch the Microdata Type dynamically&#039;&#039;&#039;, you just change the Type (there are 558 different available types).&lt;br /&gt;
# &#039;&#039;&#039;Display validated semantics&#039;&#039;&#039;, the library takes care to display data correctly.&lt;br /&gt;
# &#039;&#039;&#039;Enable/disable the microdata&#039;&#039;&#039; semantics.&lt;br /&gt;
# &#039;&#039;&#039;Fallbacks&#039;&#039;&#039;, you should never lose any meaningful semantic.&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;, that file was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article, and you setup the current scope type as &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    Here is the article text...&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And you want to add microdata semantics:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div &amp;lt;?php echo $microdata-&amp;gt;displayScope();?&amp;gt;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Alexandru Pruteanu&#039;)-&amp;gt;property(&#039;author&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Here is the article text...&#039;)-&amp;gt;property(&#039;articleBody&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div itemscope itemtype=&#039;https://schema.org/Article&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by&lt;br /&gt;
        &amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
            &amp;lt;span itemprop=&#039;name&#039;&amp;gt;Alexandru Pruteanu&amp;lt;/span&amp;gt;&lt;br /&gt;
        &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;articleBody&#039;&amp;gt;Here is the article text...&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;articleBody&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Product&#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div &amp;lt;?php echo $microdata-&amp;gt;displayScope();?&amp;gt;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Author of the content --&amp;gt;&lt;br /&gt;
    &amp;lt;span&amp;gt;&lt;br /&gt;
        Written by &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Alexandru Pruteanu&#039;)-&amp;gt;property(&#039;author&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;!-- The content --&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $microdata-&amp;gt;content(&#039;Here is the article text...&#039;)-&amp;gt;property(&#039;articleBody&#039;)-&amp;gt;display();?&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlScope($scope);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlProperty($property);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlSpan($content, $property = &amp;quot;&amp;quot;, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlMeta($content, $property, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&amp;quot;$content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with the &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;, this method does not add the meta tag in the &amp;lt;head&amp;gt; section of the page.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata = JMicrodata($type = &amp;quot;&amp;quot;, $flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;enable($flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;isEnabled();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;setType($type);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;property($name);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;content($value, $machineValue = null);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;fallback($type, $property);&#039;&#039;&#039;&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;displayScope();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;display($displayType = &amp;quot;&amp;quot;, $emptyOutput = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &amp;quot;meta&amp;quot;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;&amp;quot;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117210</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117210"/>
		<updated>2014-04-06T20:17:29Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: /* JMicrodata documentation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly.&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a library to implement and output http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The library was designed with this goals in mind:&lt;br /&gt;
# Having the &#039;&#039;&#039;possibility to switch the Microdata Type dynamically&#039;&#039;&#039;, you just change the Type (there are 558 different available types).&lt;br /&gt;
# &#039;&#039;&#039;Display validated semantics&#039;&#039;&#039;, the library takes care to display data correctly.&lt;br /&gt;
# &#039;&#039;&#039;Enable/disable the microdata&#039;&#039;&#039; semantics.&lt;br /&gt;
# &#039;&#039;&#039;Fallbacks&#039;&#039;&#039;, you should never lose any meaningful semantic.&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;, that file was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
echo &#039;Written by &#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Product&#039;);&lt;br /&gt;
echo &#039;Written by &#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlScope($scope);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlProperty($property);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlSpan($content, $property = &amp;quot;&amp;quot;, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlMeta($content, $property, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&amp;quot;$content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with the &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;, this method does not add the meta tag in the &amp;lt;head&amp;gt; section of the page.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata = JMicrodata($type = &amp;quot;&amp;quot;, $flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;enable($flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;isEnabled();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;setType($type);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;property($name);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;content($value, $machineValue = null);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;fallback($type, $property);&#039;&#039;&#039;&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;displayScope();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;display($displayType = &amp;quot;&amp;quot;, $emptyOutput = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &amp;quot;meta&amp;quot;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;&amp;quot;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117209</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117209"/>
		<updated>2014-04-06T20:15:49Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: /* JMicrodata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly.&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a library to implement and output http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The library was designed with this goals in mind:&lt;br /&gt;
# Having the &#039;&#039;&#039;possibility to switch the Microdata Type dynamically&#039;&#039;&#039;, you just change the Type (there are 558 different available types).&lt;br /&gt;
# &#039;&#039;&#039;Display validated semantics&#039;&#039;&#039;, the library takes care to display data correctly.&lt;br /&gt;
# &#039;&#039;&#039;Enable/disable the microdata&#039;&#039;&#039; semantics.&lt;br /&gt;
# &#039;&#039;&#039;Fallbacks&#039;&#039;&#039;, you should never lose any meaningful semantic.&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;, that file was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
echo &#039;Written by &#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Product&#039;);&lt;br /&gt;
echo &#039;Written by &#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlScope($scope);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlProperty($property);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlSpan($content, $property = &amp;quot;&amp;quot;, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlMeta($content, $property, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&amp;quot;$content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with the &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;, this method does not add the meta tag in the &amp;lt;head&amp;gt; section of the page.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata = JMicrodata($type = &amp;quot;&amp;quot;, $flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;enable($flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;isEnabled();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;setType($type);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;property($name);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;content($value, $machineValue = null);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;fallback($type, $property);&#039;&#039;&#039;&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;displayScope();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;display($displayType = &amp;quot;&amp;quot;, $emptyOutput = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &amp;quot;meta&amp;quot;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;&amp;quot;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117208</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117208"/>
		<updated>2014-04-06T20:01:10Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: /* How do I use the JMicrodata library? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly.&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a library to implement http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;&#039;&#039;&#039;types.json&#039;&#039;&#039;&amp;lt;/code&amp;gt; file was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
echo &#039;Written by &#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Product&#039;);&lt;br /&gt;
echo &#039;Written by &#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlScope($scope);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlProperty($property);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlSpan($content, $property = &amp;quot;&amp;quot;, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlMeta($content, $property, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&amp;quot;$content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with the &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;, this method does not add the meta tag in the &amp;lt;head&amp;gt; section of the page.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata = JMicrodata($type = &amp;quot;&amp;quot;, $flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;enable($flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;isEnabled();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;setType($type);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;property($name);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;content($value, $machineValue = null);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;fallback($type, $property);&#039;&#039;&#039;&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;displayScope();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;display($displayType = &amp;quot;&amp;quot;, $emptyOutput = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &amp;quot;meta&amp;quot;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;&amp;quot;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117207</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117207"/>
		<updated>2014-04-06T19:56:59Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly.&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a library to implement http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;&#039;&#039;&#039;types.json&#039;&#039;&#039;&amp;lt;/code&amp;gt; file was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by &#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlScope($scope);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlProperty($property);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlSpan($content, $property = &amp;quot;&amp;quot;, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlMeta($content, $property, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&amp;quot;$content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with the &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;, this method does not add the meta tag in the &amp;lt;head&amp;gt; section of the page.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata = JMicrodata($type = &amp;quot;&amp;quot;, $flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;enable($flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;isEnabled();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;setType($type);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;property($name);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;content($value, $machineValue = null);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;fallback($type, $property);&#039;&#039;&#039;&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;displayScope();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;display($displayType = &amp;quot;&amp;quot;, $emptyOutput = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &amp;quot;meta&amp;quot;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;&amp;quot;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117206</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=117206"/>
		<updated>2014-04-06T19:52:54Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly.&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a library to implement http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;&#039;&#039;&#039;types.json&#039;&#039;&#039;&amp;lt;/code&amp;gt; file was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlScope($scope);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlProperty($property);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlSpan($content, $property = &amp;quot;&amp;quot;, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlMeta($content, $property, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&amp;quot;$content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with the &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;, this method does not add the meta tag in the &amp;lt;head&amp;gt; section of the page.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata = JMicrodata($type = &amp;quot;&amp;quot;, $flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;enable($flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;isEnabled();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;setType($type);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;property($name);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;content($value, $machineValue = null);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;fallback($type, $property);&#039;&#039;&#039;&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;displayScope();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;display($displayType = &amp;quot;&amp;quot;, $emptyOutput = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &amp;quot;meta&amp;quot;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;&amp;quot;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by &#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=115081</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=115081"/>
		<updated>2014-03-10T21:57:32Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly&amp;lt;/u&amp;gt;. The following resources are available by the author of the microdata library introducing the library and how to use it:&lt;br /&gt;
*http://magazine.joomla.org/issues/issue-oct-2013/item/1551-what-about-microdata-rich-snippets-in-joomla&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a {{JVer|3.2}} [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] to implement http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;&#039;&#039;&#039;types.json&#039;&#039;&#039;&amp;lt;/code&amp;gt; file was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlScope($scope);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlProperty($property);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlSpan($content, $property = &amp;quot;&amp;quot;, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlMeta($content, $property, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&amp;quot;$content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with the &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;, this method does not add the meta tag in the &amp;lt;head&amp;gt; section of the page.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata = JMicrodata($type = &amp;quot;&amp;quot;, $flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;enable($flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;isEnabled();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;setType($type);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;property($name);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;content($value, $machineValue = null);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;fallback($type, $property);&#039;&#039;&#039;&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;displayScope();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;display($displayType = &amp;quot;&amp;quot;, $emptyOutput = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &amp;quot;meta&amp;quot;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;&amp;quot;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by &#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=115080</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=115080"/>
		<updated>2014-03-10T21:53:39Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly&amp;lt;/u&amp;gt;. The following resources are available by the author of the microdata library introducing the library and how to use it:&lt;br /&gt;
*http://magazine.joomla.org/issues/issue-oct-2013/item/1551-what-about-microdata-rich-snippets-in-joomla&lt;br /&gt;
*https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a {{JVer|3.2}} [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] to implement http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;&#039;&#039;&#039;types.json&#039;&#039;&#039;&amp;lt;/code&amp;gt; file was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlScope($scope);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlProperty($property);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlSpan($content, $property = &amp;quot;&amp;quot;, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;JMicrodata::htmlMeta($content, $property, $scope = &amp;quot;&amp;quot;, $inverse = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&amp;quot;$content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with the &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;, this method does not add the meta tag in the &amp;lt;head&amp;gt; section of the page.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata = JMicrodata($type = &amp;quot;&amp;quot;, $flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;enable($flag = true);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;isEnabled();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;setType($type);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;property($name);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;content($value, $machineValue = null);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;fallback($type, $property);&#039;&#039;&#039;&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;displayScope();&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&#039;&#039;&#039;$microdata-&amp;gt;display($displayType = &amp;quot;&amp;quot;, $emptyOutput = false);&#039;&#039;&#039;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &amp;quot;meta&amp;quot;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;&amp;quot;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by &#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106436</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106436"/>
		<updated>2013-12-13T18:58:04Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly&amp;lt;/u&amp;gt;. The following resources are available by the author of the microdata library introducing the library and how to use it:&lt;br /&gt;
*http://magazine.joomla.org/issues/issue-oct-2013/item/1551-what-about-microdata-rich-snippets-in-joomla&lt;br /&gt;
*https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a {{JVer|3.2}} [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] to implement http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;types.json&amp;lt;/code&amp;gt; was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
JMicrodata::htmlScope($scope);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/big&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&amp;lt;code&amp;gt;&lt;br /&gt;
JMicrodata::htmlProperty($property);&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&amp;lt;code&amp;gt;&lt;br /&gt;
JMicrodata::htmlSpan($content, $property = &#039;&#039;, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;big&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
JMicrodata::htmlMeta($content, $property, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&#039;$content&#039;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;big&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$microdata = JMicrodata($type = &#039;&#039;, $flag = true);&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&amp;lt;code&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable($flag = true);&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;big&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;isEnabled();&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;big&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;setType($type);&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;big&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;property($name);&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&amp;lt;code&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;content($value, $machineValue = null);&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&amp;lt;code&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;fallback($type, $property);&lt;br /&gt;
&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt;Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;big&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;displayScope();&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;big&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;display($displayType = &#039;&#039;, $emptyOutput = false);&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &#039;meta&#039;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by&#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106435</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106435"/>
		<updated>2013-12-13T18:55:46Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly&amp;lt;/u&amp;gt;. The following resources are available by the author of the microdata library introducing the library and how to use it:&lt;br /&gt;
*http://magazine.joomla.org/issues/issue-oct-2013/item/1551-what-about-microdata-rich-snippets-in-joomla&lt;br /&gt;
*https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a {{JVer|3.2}} [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] to implement http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;types.json&amp;lt;/code&amp;gt; was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
JMicrodata::htmlScope($scope);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/big&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&amp;lt;code&amp;gt;&lt;br /&gt;
JMicrodata::htmlProperty($property);&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&amp;lt;code&amp;gt;&lt;br /&gt;
JMicrodata::htmlSpan($content, $property = &#039;&#039;, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;big&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
JMicrodata::htmlMeta($content, $property, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&#039;$content&#039;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = JMicrodata($type = &#039;&#039;, $flag = true);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&amp;lt;code&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable($flag = true);&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;big&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;isEnabled();&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;big&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;setType($type);&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;big&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;property($name);&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&amp;lt;code&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;content($value, $machineValue = null);&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&amp;lt;code&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;fallback($type, $property);&lt;br /&gt;
&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt;Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;big&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;displayScope();&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;big&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;display($displayType = &#039;&#039;, $emptyOutput = false);&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/big&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &#039;meta&#039;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by&#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106434</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106434"/>
		<updated>2013-12-13T18:51:13Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly&amp;lt;/u&amp;gt;. The following resources are available by the author of the microdata library introducing the library and how to use it:&lt;br /&gt;
*http://magazine.joomla.org/issues/issue-oct-2013/item/1551-what-about-microdata-rich-snippets-in-joomla&lt;br /&gt;
*https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a {{JVer|3.2}} [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] to implement http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;types.json&amp;lt;/code&amp;gt; was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
JMicrodata::htmlScope($scope);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/big&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlProperty($property);&lt;br /&gt;
&amp;lt;/source&amp;gt;&amp;lt;/big&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlSpan($content, $property = &#039;&#039;, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&amp;lt;/big&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlMeta($content, $property, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&#039;$content&#039;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = JMicrodata($type = &#039;&#039;, $flag = true);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable($flag = true);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;isEnabled();&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;setType($type);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;property($name);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;content($value, $machineValue = null);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;fallback($type, $property);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;displayScope();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;display($displayType = &#039;&#039;, $emptyOutput = false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &#039;meta&#039;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by&#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106433</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106433"/>
		<updated>2013-12-13T18:50:23Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;As of &#039;&#039;&#039;Joomla!&#039;&#039;&#039; {{JVer|3.2}} there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly&amp;lt;/u&amp;gt;. The following resources are available by the author of the microdata library introducing the library and how to use it:&lt;br /&gt;
*http://magazine.joomla.org/issues/issue-oct-2013/item/1551-what-about-microdata-rich-snippets-in-joomla&lt;br /&gt;
*https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] is a {{JVer|3.2}} [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] to implement http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org &amp;lt;i&amp;gt;Types&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Properties&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;types.json&amp;lt;/code&amp;gt; was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlScope($scope);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/big&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlProperty($property);&lt;br /&gt;
&amp;lt;/source&amp;gt;&amp;lt;/big&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlSpan($content, $property = &#039;&#039;, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&amp;lt;/big&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlMeta($content, $property, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&#039;$content&#039;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = JMicrodata($type = &#039;&#039;, $flag = true);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable($flag = true);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;isEnabled();&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;setType($type);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;property($name);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;content($value, $machineValue = null);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;fallback($type, $property);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;displayScope();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;display($displayType = &#039;&#039;, $emptyOutput = false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &#039;meta&#039;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by&#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106430</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106430"/>
		<updated>2013-12-13T12:11:49Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the Microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;As of &#039;&#039;&#039;Joomla! 3.2&#039;&#039;&#039; there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly&amp;lt;/u&amp;gt;. The following resources are available by the author of the microdata library introducing the library and how to use it:&lt;br /&gt;
*http://magazine.joomla.org/issues/issue-oct-2013/item/1551-what-about-microdata-rich-snippets-in-joomla&lt;br /&gt;
*https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] (since version 3.2) is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] to implement http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org Types and Properties.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The types.json was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlScope($scope);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlProperty($property);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlSpan($content, $property = &#039;&#039;, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlMeta($content, $property, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&#039;$content&#039;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = JMicrodata($type = &#039;&#039;, $flag = true);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable($flag = true);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;isEnabled();&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;setType($type);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;property($name);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;content($value, $machineValue = null);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;fallback($type, $property);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;displayScope();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;display($displayType = &#039;&#039;, $emptyOutput = false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &#039;meta&#039;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by&#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106429</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106429"/>
		<updated>2013-12-13T12:07:21Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the Microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;As of &#039;&#039;&#039;Joomla! 3.2&#039;&#039;&#039; there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly&amp;lt;/u&amp;gt;. The following resources are available by the author of the microdata library introducing the library and how to use it:&lt;br /&gt;
*http://magazine.joomla.org/issues/issue-oct-2013/item/1551-what-about-microdata-rich-snippets-in-joomla&lt;br /&gt;
*https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] (since version 3.2) is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] to implement http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org Types and Properties.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The types.json was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For a more detailed documentation of the library see the gist created by the author:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlScope($scope);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlProperty($property);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlSpan($content, $property = &#039;&#039;, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlMeta($content, $property, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&#039;$content&#039;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = JMicrodata($type = &#039;&#039;, $flag = true);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable($flag = true);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;isEnabled();&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;setType($type);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;property($name);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;content($value, $machineValue = null);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;fallback($type, $property);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;displayScope();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;display($displayType = &#039;&#039;, $emptyOutput = false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &#039;meta&#039;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
* normal → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by&#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106428</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106428"/>
		<updated>2013-12-13T12:04:07Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
&lt;br /&gt;
{{underconstruction}}&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the Microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;As of &#039;&#039;&#039;Joomla! 3.2&#039;&#039;&#039; there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly&amp;lt;/u&amp;gt;. The following resources are available by the author of the microdata library introducing the library and how to use it:&lt;br /&gt;
*http://magazine.joomla.org/issues/issue-oct-2013/item/1551-what-about-microdata-rich-snippets-in-joomla&lt;br /&gt;
*https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] (since version 3.2) is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] to implement http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org Types and Properties.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The types.json was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For a more detailed documentation of the library see the gist created by the author:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlScope($scope);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlProperty($property);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlSpan($content, $property = &#039;&#039;, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlMeta($content, $property, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&#039;$content&#039;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = JMicrodata($type = &#039;&#039;, $flag = true);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable($flag = true);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;isEnabled();&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;setType($type);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;property($name);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;content($value, $machineValue = null);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;fallback($type, $property);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;displayScope();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;display($displayType = &#039;&#039;, $emptyOutput = false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
* inline&lt;br /&gt;
* span&lt;br /&gt;
* html&lt;br /&gt;
* meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &#039;meta&#039;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;lt;/source&amp;gt;, if there is also available a $content it will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemprop=&amp;quot;$property&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;gt;$content&amp;lt;/span&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta content=&amp;quot;$content&amp;quot; itemprop=&amp;quot;$property&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;, if no $content is available will output &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
* normal → example: itemprop=&amp;quot;$property&amp;quot;&amp;lt;/source&amp;gt;, if there is available a $content will output &amp;lt;span itemprop=&amp;quot;$property&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by&#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106427</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106427"/>
		<updated>2013-12-13T11:56:28Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
&lt;br /&gt;
{{underconstruction}}&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the Microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;As of &#039;&#039;&#039;Joomla! 3.2&#039;&#039;&#039; there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly&amp;lt;/u&amp;gt;. The following resources are available by the author of the microdata library introducing the library and how to use it:&lt;br /&gt;
*http://magazine.joomla.org/issues/issue-oct-2013/item/1551-what-about-microdata-rich-snippets-in-joomla&lt;br /&gt;
*https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] (since version 3.2) is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] to implement http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org Types and Properties.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The types.json was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For a more detailed documentation of the library see the gist created by the author:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlScope($scope);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlProperty($property);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlSpan($content, $property = &#039;&#039;, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlMeta($content, $property, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&#039;$content&#039;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = JMicrodata($type = &#039;&#039;, $flag = true);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable($flag = true);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;isEnabled();&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;setType($type);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;property($name);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;content($value, $machineValue = null);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;fallback($type, $property);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;displayScope();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;display($displayType = &#039;&#039;, $emptyOutput = false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
    * inline&lt;br /&gt;
    * span&lt;br /&gt;
    * html&lt;br /&gt;
    * meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &#039;meta&#039;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
* nested → example: itemprop=&amp;quot;author&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/Person, if there is also available a $content it will output &amp;lt;span itemprop=&amp;quot;author&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/Person&amp;gt;$content&amp;lt;/span&amp;gt;&lt;br /&gt;
* meta → example: &amp;lt;meta content=&amp;quot;2011-01-01&amp;quot; itemprop=&amp;quot;datePublished&amp;quot;&amp;gt;, if no $content is available will output itemprop=&amp;quot;datePublished&amp;quot;&lt;br /&gt;
* normal → example: itemprop=&amp;quot;author&amp;quot;, if there is available a $content will output &amp;lt;span itemprop=&amp;quot;author&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&lt;br /&gt;
==How do I use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by&#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106426</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106426"/>
		<updated>2013-12-13T11:53:26Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
&lt;br /&gt;
{{underconstruction}}&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the Microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;As of &#039;&#039;&#039;Joomla! 3.2&#039;&#039;&#039; there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly&amp;lt;/u&amp;gt;. The following resources are available by the author of the microdata library introducing the library and how to use it:&lt;br /&gt;
*http://magazine.joomla.org/issues/issue-oct-2013/item/1551-what-about-microdata-rich-snippets-in-joomla&lt;br /&gt;
*https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] (since version 3.2) is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] to implement http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org Types and Properties.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The types.json was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For a more detailed documentation of the library see the gist created by the author:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlScope($scope);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlProperty($property);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlSpan($content, $property = &#039;&#039;, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlMeta($content, $property, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&#039;$content&#039;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = JMicrodata($type = &#039;&#039;, $flag = true);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable($flag = true);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;isEnabled();&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;setType($type);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;property($name);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;content($value, $machineValue = null);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;fallback($type, $property);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;displayScope();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Return: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML with the &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inserted inside a tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;display($displayType = &#039;&#039;, $emptyOutput = false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Return the Microdata HTML, if the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; isn&#039;t available it checks for a Fallback, otherwise return &#039;&#039;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 4 types of $displayType:&lt;br /&gt;
    *inline&lt;br /&gt;
    *span&lt;br /&gt;
    *html&lt;br /&gt;
    *meta&lt;br /&gt;
&amp;lt;u&amp;gt;This method contains the HTML Microdata display logic&amp;lt;/u&amp;gt;,&lt;br /&gt;
If you specify the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param, the Microdata will be returned the way you specified and expect — to,&lt;br /&gt;
Otherwise if the &amp;lt;i&amp;gt;$displayType&amp;lt;/i&amp;gt; param is empty it will be processed by the &amp;lt;i&amp;gt;display()&amp;lt;/i&amp;gt; method and returned the HTML in the right way, with the expected &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; Type (example of expectedTypes = URL, Text, Person ...)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happens if you call display($displayType = &#039;meta&#039;) ?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The returned HTML will be inside a &amp;lt;meta&amp;gt; HTML tag.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
— What happend if you call display()?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The method will automatically check the expected type for the given Property, and will return the right Microdata HTML.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are 3 types of Microdata:&lt;br /&gt;
    *nested → example: itemprop=&amp;quot;author&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/Person, if there is also available a $content it will output &amp;lt;span itemprop=&amp;quot;author&amp;quot; itemscope itemtype=&amp;quot;http://schema.org/Person&amp;gt;$content&amp;lt;/span&amp;gt;&lt;br /&gt;
    *meta → example: &amp;lt;meta content=&amp;quot;2011-01-01&amp;quot; itemprop=&amp;quot;datePublished&amp;quot;&amp;gt;, if no $content is available will output itemprop=&amp;quot;datePublished&amp;quot;&lt;br /&gt;
    *normal → example: itemprop=&amp;quot;author&amp;quot;, if there is available a $content will output &amp;lt;span itemprop=&amp;quot;author&amp;quot;&amp;gt;$content&amp;lt;/span&amp;gt;&lt;br /&gt;
==How to use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that you have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by&#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106425</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106425"/>
		<updated>2013-12-12T21:59:29Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
&lt;br /&gt;
{{underconstruction}}&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To understand how search engines use the Microdata information take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;As of &#039;&#039;&#039;Joomla! 3.2&#039;&#039;&#039; there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly&amp;lt;/u&amp;gt;. The following resources are available by the author of the microdata library introducing the library and how to use it:&lt;br /&gt;
*http://magazine.joomla.org/issues/issue-oct-2013/item/1551-what-about-microdata-rich-snippets-in-joomla&lt;br /&gt;
*https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] (since version 3.2) is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] to implement http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org Types and Properties.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The types.json was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For a more detailed documentation of the library see the gist created by the author:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==JMicrodata documentation==&lt;br /&gt;
All Microdata HTML output is handled by the JMicrodata class.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlScope($scope);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemscope itemtype=&amp;quot;http://schema.org/$scope&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML &amp;lt;i&amp;gt;Scope&amp;lt;/i&amp;gt; of the given &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlProperty($property);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
itemprop=&amp;quot;$property&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the HTML of the given &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, must be inside a HTML tag element.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlSpan($content, $property = &#039;&#039;, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span itemscope itemtype=&amp;quot;http://schema.org/$scope itemprop=&amp;quot;$property&amp;quot;&amp;gt;&lt;br /&gt;
    $content&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;span&amp;gt; tag, there is also available a JMicrodata::htmlDiv() method with the same functionalities.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JMicrodata::htmlMeta($content, $property, $scope = &#039;&#039;, $inverse = false);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta $property $scope content=&#039;$content&#039;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
the microdata in a &amp;lt;meta&amp;gt; tag with &amp;lt;i&amp;gt;content for machines&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = JMicrodata($type = &#039;&#039;, $flag = true);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Create a new instance of the &amp;lt;i&amp;gt;JMicrodata&amp;lt;/i&amp;gt; class and setup the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, the flag param is for enabling or disabling HTML microdata semantics output. Fallback to &amp;lt;i&amp;gt;Thing&amp;lt;/i&amp;gt; Type if the Type isn&#039;t available or given.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable($flag = true);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Enable or Disable HTML Microdata semantics output.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;isEnabled();&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Return true if Microdata semantics HTML output are enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;setType($type);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Set a new Schema.org &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;, there is also a $microdata-&amp;gt;getType() function to retrieve the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;property($name);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup the &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt; if available in the current &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; Scope, there is also a $microdata-&amp;gt;getProperty() function to retrieve the current &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;content($value, $machineValue = null);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup a &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt; or &amp;lt;i&amp;gt;Content value&amp;lt;/i&amp;gt; for the Microdata, there is also a $microdata-&amp;gt;getContent() function to retrieve the current &amp;lt;i&amp;gt;Text value&amp;lt;/i&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;fallback($type, $property);&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
Setup a Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;, there are also the $microdata-&amp;gt;getFallbackType() and $microdata-&amp;gt;getFallbackProperty() to retrieve the Fallback &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; and Fallback &amp;lt;i&amp;gt;Property&amp;lt;/i&amp;gt;. Fallback to &amp;lt;i&amp;gt;Thing Type&amp;lt;/i&amp;gt; if the &amp;lt;i&amp;gt;Type&amp;lt;/i&amp;gt; isn&#039;t available, Fallback to &amp;lt;i&amp;gt;null&amp;lt;/i&amp;gt; the Property if isn&#039;t available.&lt;br /&gt;
==How to use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that we have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by&#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106424</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106424"/>
		<updated>2013-12-12T21:21:26Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
&lt;br /&gt;
{{underconstruction}}&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Take a look at [https://www.youtube.com/watch?v=A-kX0Aut-18 this short video] to see how search engines use the Microdata information.&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;As of &#039;&#039;&#039;Joomla! 3.2&#039;&#039;&#039; there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] within Joomla! which allows developers to pull in microdata without needing to format it correctly&amp;lt;/u&amp;gt;. The following resources are available by the author of the microdata library introducing the library and how to use it:&lt;br /&gt;
*http://magazine.joomla.org/issues/issue-oct-2013/item/1551-what-about-microdata-rich-snippets-in-joomla&lt;br /&gt;
*https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==JMicrodata==&lt;br /&gt;
[https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/microdata.php JMicrodata] (since version 3.2) is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata library] to implement http://schema.org microdata semantics.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The JMicrodata class uses the [https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/microdata/types.json types.json] file which contains all available http://schema.org Types and Properties.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The types.json was automatically created with the https://github.com/PAlexcom/Spider4Schema web crawler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For some usage examples you can see the library test file https://github.com/joomla/joomla-cms/blob/master/tests/unit/suites/libraries/joomla/microdata/JMicrodataTest.php&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For a more detailed documentation of the library see the gist created by the author:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==How to use the JMicrodata library?==&lt;br /&gt;
First of all you need to make an instance of the library in your extensions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata = new JMicrodata(&#039;Article&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
So let&#039;s suppose that we have the following string which is part of your article and the current scope is &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by Alexandru Pruteanu&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And the microdata you need to add is an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &#039;Written by&#039; . $microdata-&amp;gt;content(“Alexandru Pruteanu”)-&amp;gt;property(&#039;author&#039;)-&amp;gt;fallback(&#039;Person&#039;, &#039;name&#039;)-&amp;gt;display();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemprop=&#039;author&#039; itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if the current scope is something else than &amp;lt;i&amp;gt;Article&amp;lt;/i&amp;gt;, for example a &amp;lt;i&amp;gt;Product&amp;lt;/i&amp;gt; scope, and the current scope doesn&#039;t have an &amp;lt;i&amp;gt;author&amp;lt;/i&amp;gt; property?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Well it will fallback in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by&lt;br /&gt;
&amp;lt;span itemscope itemtype=&#039;https://schema.org/Person&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;span itemprop=&#039;name&#039;&amp;gt;&lt;br /&gt;
        Alexandru Pruteanu&lt;br /&gt;
    &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If I want to disable the microdata semantics output?&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
You can simply disable the microdata output by calling the following function:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$microdata-&amp;gt;enable(false);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The library will display the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Written by Alexandru Pruteanu&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106423</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106423"/>
		<updated>2013-12-12T20:27:07Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: /* How do I use Microdata? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
&lt;br /&gt;
{{underconstruction}}&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As of &#039;&#039;&#039;Joomla! 3.2&#039;&#039;&#039; there is a [https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata 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:&lt;br /&gt;
*http://magazine.joomla.org/issues/issue-oct-2013/item/1551-what-about-microdata-rich-snippets-in-joomla&lt;br /&gt;
*https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106341</id>
		<title>Microdata</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Microdata&amp;diff=106341"/>
		<updated>2013-12-08T18:31:43Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
==What is Microdata?==&lt;br /&gt;
&lt;br /&gt;
{{underconstruction}}&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Contextual information allows search engines to understand the meaning of the information presented on your website, which allows it to better answer more verbose &#039;natural language&#039; queries where an understanding of the meaning helps to interpret the most relevant content to be displayed.&lt;br /&gt;
&lt;br /&gt;
Microdata can be used to explain just about anything you would ever want to explain, and there are more &#039;schemas&#039; being added on a regular basis.  There are several vocabularies in existence, however at present the system favoured by search engines is that of [https://schema.org schema.org].&lt;br /&gt;
&lt;br /&gt;
==How do I use Microdata?==&lt;br /&gt;
Microdata can be added to Joomla! using template overrides or with the use of plugins which allow you to insert microdata into specific resources.&lt;br /&gt;
&lt;br /&gt;
As of Joomla! 3.2 there is a library within Joomla! which allows developers to pull in microdata without needing to format it correctly. Currently, the following articles are available by the author of the microdata library:&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
http://magazine.joomla.org/issues/issue-oct-2013/item/1551-what-about-microdata-rich-snippets-in-joomla&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
https://gist.github.com/PAlexcom/6339949&lt;br /&gt;
&lt;br /&gt;
==How To implement Microdata yourself==&lt;br /&gt;
* [[How To Implement Rich Snippet for Breadcrumbs]]&lt;br /&gt;
[[Category:Search Engine Optimisation]]&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:P.Alex&amp;diff=106340</id>
		<title>User:P.Alex</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:P.Alex&amp;diff=106340"/>
		<updated>2013-12-08T18:27:54Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi, I&#039;m a young web master born in Moldavia and I love the web. Now, I&#039;m living in Italy where I&#039;m studies Web &amp;amp; Multimedia Technologies at the University of Udine. I wake up every morning with the desire to learn something damn new and always try to widen my knowledge. Currently I&#039;m working on several projects putting together experience, passion and creativity.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Also a happy Linux user, and a Open Source advocate.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
https://twitter.com/PAlexcom&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
http://p-alex.com&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:P.Alex&amp;diff=106339</id>
		<title>User:P.Alex</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:P.Alex&amp;diff=106339"/>
		<updated>2013-12-08T18:21:39Z</updated>

		<summary type="html">&lt;p&gt;P.Alex: Created page with &amp;quot;Hi, I&amp;#039;m a young web master born in Moldavia and I love the web. Now, I&amp;#039;m living in Italy where I&amp;#039;m studies Web &amp;amp; Multimedia Technologies at the University of Udine. I wake up ...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi, I&#039;m a young web master born in Moldavia and I love the web. Now, I&#039;m living in Italy where I&#039;m studies Web &amp;amp; Multimedia Technologies at the University of Udine. I wake up every morning with the desire to learn something damn new and always try to widen my knowledge. Currently I&#039;m working on several projects putting together experience, passion and creativity.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Also a happy Linux user, and a Open Source advocate.&lt;/div&gt;</summary>
		<author><name>P.Alex</name></author>
	</entry>
</feed>