The Joomla! Community Magazine™

Joomla! Semantics (Microdata, RDFa)

Written by | Sunday, 01 June 2014 00:00 | Published in 2014 June
The goal is to implement Microdata semantics in the CMS using the JMicrodata library, and create a RDFa library, so that you can choose the type of semantics to display: Microdata or RDFa.
Joomla! Semantics (Microdata, RDFa) Joomla! Semantics (Microdata, RDFa) Alexandru Pruteanu

Project in detail

This type of project involves considerable research in the area of web standards and must maintain valid HTML. During the last edition of Google Summer of Code 2013, with the project: Improve Joomla! Frontend semantics and Accessibility, the JMicrodata library was created, which displays semantic microdata. That library was merged in the Joomla CMS libraries and has been available since version 3.2.

At the moment that library isn’t used to implement microdata semantics in the CMS, but the 3.3 release introduced microdata semantics into two of the core component’s layouts, this implementation is, however, a simple hard-coded HTML version of microdata semantics.

That solution was discussed for a long time, unfortunately the focus and feedback on microdata and  the JMicrodata library arrived after the library was created, but not during the design and development. Fortunately now there is a lot of feedback and we know what is needed. In short, the decision to implement a hardcoded version of microdata in the 3.3 release was made because the JMicrodata library isn't as easy and intuitive to use as we'd like. The implementation of JMicrodata Library was a little too complex as it required quite detailed knowledge of coding techniques

At the moment there isn't an ideal solution on how to implement the JMicrodata library in the CMS, as a result of the discussions around the pull requests several ideas and proposed solutions have been raised. Even if it seems that displaying some simple HTML tags is easy, it becomes complex if we want to have the possibility to switch between 558 different microdata types, in that case the problem becomes complex.

Let’s see why the hardcoded version was implemented for the moment in the 3.3 release:

What JMicrodata does:

  1. Having the possibility to switch the Microdata Type dynamically, you just change the Type (there are 558 different available types).
  2. Display validated semantics, the library takes care of displaying data in the correct format (e.g. all the dates in the ISO standard).
  3. Enable/disable the microdata semantics, within Joomla, with a simple switch, rather than having to make changes to the template overrides.
  4. Fallbacks, you should never lose any meaningful semantic (e.g. if you switch the page type and it doesn’t have an author property it will fallback to the Person type with the name property).

Even if it has some nice features, there is a small problem, for example:

Written by <?php echo $microdata->content('P.Alex')->property('author')->fallback('Person', 'name')->display();?>

Will render:

Written by
<span itemprop='author' itemscope itemtype='https://schema.org/Person'>
    <span itemprop='name'>
        P.Alex
    </span>
</span>

As you can see, just to display the P.Alex word there is too much PHP code that isn’t so easy and intuitive. So the goal of this project is to simplify and create a solution to implement that library in the CMS. An implementation that needs to be simple and intuitive to use, so that under the hood the complex work is done by the JMicrodata library:

That said, the new roadmap is:

  1. Having the possibility to switch the Microdata Type dynamically, you just change the Type (there are 558 different available types).
  2. Display validated semantics, the library takes care of displaying data in the correct format (e.g. all the dates in the ISO standard).
  3. Enable/disable the microdata semantics, within Joomla, with a simple switch, rather than having to make changes to the template overrides.
  4. Fallbacks, you should never lose any meaningful semantic (e.g. if you switch the page type and it doesn’t have an author property it will fallback to the Person type with the name property).
  5. A simple, intuitive way to implement and use the library in the CMS
  6. Possibility to switch between Microdata and RDFa semantics

As you have noticed in the current roadmap a RDFa library should be created, in order to have the possibility to switch between Microdata and RDFa semantics. The library needs to be reusable even outside of Joomla! CMS. To implement these features I'll have to change the user interface in configuration options and the output of various components such as com_content, com_contact and also the default templates.

If you want to help, contribute, you have a possible solution or idea on how to solve those problems we could discuss about it. (@PAlexcom)

About me

I've participated to the previous edition of Google Summer of Code 2013 with the project: Improve Joomla! Frontend Semantics & Accessibility for the Joomla organization. During the GSoC program I've created the JMicrodata library which is now available in the CMS from version 3.2.

I build my websites with Joomla! since version 1.5

My name is Alexandru Pruteanu (P.Alex), 23 years old and believe me, I love the web. Now, I’m living in Italy and I’m studying Web Technology and Multimedia at the University of Udine. I wake up every morning with the desire to learn something new and always try to widen my knowledge.

Conclusion

In short at the end of the project a new RDFa library should be created and both Microdata and RDFa implemented in a simple to use way in the Joomla CMS. I would like to the thank Joomla organization for giving me the opportunity to work on this great project. Also special thanks to Ruth Cheesley and Matt Thomas for mentoring me, and to Google Inc. for the amazing "Google Summer of Code" program that helps Open Source organizations.

Read 4085 times
Tagged under Google Summer of Code, English
Alexandru Pruteanu

Alexandru Pruteanu

A young Web Engineer born in Moldavia who loves the web. Now, he is living in Italy where he studies Web Technologies & Multimedia at the University of Udine. He wakes up every day with the desire to learn something new and always tries to widen his knowledge. He is a happy Linux user, and a Open Source advocate. Currently he is working on several projects putting together experience, passion and creativity. His home page is http://p-alex.com or you can find him on Twitter (@PAlexcom).