What about Microdata in Joomla?
A couple of months ago I wrote an article about my Google Summer of Code project, which aimed to add microdata semantics in the Joomla CMS. Now lets take a closer look at the status of this project to see what has been done.
Here you can find my previous article in the Joomla Magazine about my Google Summer of Code project: Improve Joomla! Frontend Semantics & Accessibility
If you are not familiar with microdata please see this quick one minute video: https://www.youtube.com/watch?v=A-kX0Aut-18
This type of project involved considerable research with web standards and continuous testing to maintain valid HTML. The microdata library also needs to be flexible, fast, light, and easy-intuitive to use for developers. So I must admit that the library changed more than once the design architecture, in order to maintain the previous listed properties.
So, after a month of research and testing the library was finally merged in the Joomla CMS master branch, which you will be able to use from the next Joomla 3.2 version. If you are a developer you can use that library to implement microdata semantics in your extensions.
If you want to take a closer look, here you can find the library: libraries/joomla/microdata
How to use the JMicrodata library?
To use the new microdata semantics library you need to make an instance of the library in your extensions.
$microdata = new JMicrodata('Article');
So let's suppose that we have the following string:
Written by Alexandru Pruteanu
And we need to add an author property:
echo 'Written by' . $microdata->content(“Alexandru Pruteanu”)->property('author')->fallback('Person', 'name')->display();
The library will display:
Written by <span itemprop='author' itemscope itemtype='https://schema.org/Person'> <span itemprop='name'> Alexandru Pruteanu </span> </span>
What happens if the current scope is something other than 'Article', for example a 'Product' scope, and the current scope doesn't have an author property?
Well it will fall back in:
<span itemscope itemtype='https://schema.org/Person'> <span itemprop='name'> Alexandru Pruteanu </span> </span>
If we want to disable the microdata semantics output?
You can simply disable the microdata output:
The library will display the following:
Written by Alexandru Pruteanu
For further documentation please take a look at this Gist: https://gist.github.com/PAlexcom/6339949
Or just simply contact me, I'll surely talk with you ;)
What about the implementation in the Joomla CMS?
This is just a proposal that needs to be accepted, nothing of what is showed below is implemented yet in the official Joomla CMS versions.
While I'm telling you this I'm also working on the implementation in the CMS, there is already a pull request, but as it involves a lot of changes in the CMS it needs more testing.
Below you can find a live site with microdata semantics implemented: Joomla Live Site with Microdata Semantics
Here is what the Google Rich snippets tool can extract:
Click here to make a live test, (refresh or press 'PREVIEW' if it doesn't work)
But how it's implemented in the Joomla CMS administration area?
You can enable/disable the microdata semantics from the Global Configuration.
EXAMPLE: Administration → Global Configuration → Site (tab) → SEO Setting
You can enable/disable the microdata semantics output from the Article editing options, and also select the scope.
What are the current issues?
Well, the biggest issue for the moment is that you can't switch from Microdata to RFDa or Microformats, but you can't even change the vocabulary. So we need a way to figure out how to make that possible.
At the time of this writing there is an issue with the necessity of having a JMicrodata global instance, otherwise everything will crash.
For me working with the Joomla Team/Developers and being part of the Google Summer of Code program has been an awesome and interesting experience. I've learned a lot and especially how an Open Source project is maintained and how people from different parts of the world work together. But even if the GSoC program has finished I would like to keep working on that project and also add new features. For any problems you might have with the library usage, any innovative ideas or if you want to give me a hand just let me know, I'm Alexandru Pruteanu and I'll be certainly glad to talk with you ;)
By accepting you will be accessing a service provided by a third-party external to https://magazine.joomla.org/