There has been a prominent announcement from Google, Yahoo, and Bing that they are going to support microdata for their http://schema.org vocabulary. While I believe they do intend to support RDFa for that as well at some point in the future, there seems to be some momentum behind microdata, so hopefully we can combine the RDF and microdata efforts to provide data interoperability to the widest range of consumers.

Entity referencing fields that are based on Entity API work perfectly for RDFa without modification. The field wrapper contains the attribute name and the output of the field formatter is used as the value. Unfortunately, because microdata requires that both the attribute name and value be included in the same tag, we need to make a minor modification for proper microdata Field Collection values.

I will attach a patch that includes support for the API in its current state. I don't recommend committing this until microdata module moves into RC, but I wanted this patch to be here so people could test.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

FileSize
756 bytes

This patch ensures that itemscope isn't placed on entities that are within fields.

tim.plunkett’s picture

Status: Active » Needs review

Will test soon. I *really* wish there was a hook_field_formatter_view_alter()!

Anonymous’s picture

FileSize
1.05 KB

Updated for current API.

Status: Needs review » Needs work

The last submitted patch, 1199028-03-microdata.patch, failed testing.

Anonymous’s picture

Status: Needs work » Needs review
FileSize
1.97 KB

I removed the microdata_top_level_item flag because it was too confusing.

Because the parent entity is available by reference, it's possible to pull the itemprop attribute that would normally go on the field wrapper. These are then combined with the item attributes for the Field Collection itself and added to the '#attributes' array.

I'm feeling pretty comfortable with this pattern for reference fields. Please let me know if you have any comments or suggestions, I'm trying to work out all the remaining API WTFs now, before I move to beta.

The module isn't at RC yet, but I think I'm getting close to beta. I'll post here when it's in RC.

Anonymous’s picture

FileSize
513 bytes

The modifications I made to Microdata module to support Views and Panels made reference fields super easy.

Here's the patch :)

dasjo’s picture

tried with the dev version of microdata.

when editing a field of a field_collection, i see a message with a link:

No itemtype has been defined for Field collection my_field. Define one on the Field collection my_field edit page.

the link takes me to the field_collection manage fields page, where i don't see anything specific for microdata.

content types have an edit page, while field_collections don't

Anonymous’s picture

yeah, I would like to be able to have everything editable from the content type (or generically, the bundle) edit page.

However, since there isn't a bundle edit page for field_collection, you can go to admin/config/services/microdata and set it there. I haven't tested that UI lately, but it uses the same code so it should work.

dasjo’s picture

thanks for the pointer, didn't know about this UI :)
so i guess, either should the link point to the working UI or we ask field_collection to have an edit page as well

Anonymous’s picture

Yeah, I'd be happy to have community feedback on the best way to handle this across different entity types.

klonos’s picture

Besides doing actual code-review on the patch in #6, what need to be tested and confirmed as working (besides the obvious I mean)?