Hi there - I hope this isn't too grossly miscategorized. I also searched for "RDF," "hCalendar," "microformats" in the issue queue first, but no luck. I didn't want to put it as a feature request yet either because it'd be redundant in Drupal 7 anyway, and it might not be worth it.

Anyway, getting to the point. I'm working on implementing RDFa markup on a Drupal site to facilitate getting parsed by Google's Rich Snippets parser - http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=164506

There is somewhat painfully little on this out there - there's like one Drupal Group talking about it, and the odd attempt here and there, but nothing conclusive. I figured out that I can override date.theme's theme functions in my theme to achieve this, but I hit a problem because I wind up having to override theme_date_display_combination, which is quite hefty. If that function (or other date.theme functions that I override) changes in a later release, it'll be a bit of a maintainability issue, even if I leave notes above my theme overrides.

Is there a better way to do this? The problem I face is that in order to output good markup, I need the ISO-formatted date. However, by the time it gets to most of the smaller theme functions, it's already been formatted and timezone-adjusted. I think it might have even already been timezone-adjusted by when it hits theme_date_display_combination. Anyway, by reading that link above and clicking RDFa you can get an idea of what I'm trying to output.

Another idea I had was to do all the magic in a Views field override, because they're ultimately being output by a view, and I only need this for that view for the moment. But again I run into the need to override the theme functions anyway.

I think I'm probably doing things the most reasonable way given what's available and given that it is an undertaking of small scope. Just figured I'd hit up the community a bit to get some feedback. Let me know what you think!

Thanks,
Kevin

CommentFileSizeAuthor
#4 821200_4_date_rdfa.patch2.17 KBscor
#3 821200_3_date_rdfa.patch1.59 KBscor
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gwtt’s picture

If there's a better place to put this let me know...for now I'll just go ahead as I was. It's not a date-heavy use case so I doubt any future fixes will have such an immediate effect that it'll be of concern anyway. This is what theme functions are for after all...

But if anyone's got any comments, let me know. Thanks.

scor’s picture

Title: Supporting RDFa - any recommendations? » RDFa support in date markup
Version: 6.x-2.4 » 7.x-2.x-dev
Component: Miscellaneous » Code
Category: support » feature

@gwtt: Supporting RDFa in Drupal 6 is not very easy. Drupal 7 is recommended if you want RDFa.

To support RDFa, date.module needs to add a content attribute with the ISO value of the date (results of date_iso8601()). I'll try to roll a patch asap.

scor’s picture

Status: Active » Needs review
FileSize
1.59 KB

Here is a patch that adds the date ISO as part of the processed date data so that it can be added in the theme function in the content attribute.

scor’s picture

FileSize
2.17 KB

the hunk for the theme function was missing.

KarenS’s picture

Status: Needs review » Needs work

So it looks like this only handles a date without a 'To date'. I'm trying to see what is needed so both the 'From' and 'To' dates get marked up.

KarenS’s picture

Status: Needs work » Fixed

I tried to dig into the RDF requirements as well as looking at modules like the Schema.org module to see how I could provide some default functionality for people who don't want to figure this all out and also to support various other things people might want to do (like enabling the Schema.org module and marking the content type as an event). I ended up passing attributes on to the theme as well as any entity mapping I could find, and set up some default property types to use if nothing else was passed in.

I suspect there may be more we could/should do, but hopefully this is a pretty good pass at getting this working right. I added some text to README.txt to try to explain how it could work.

scor’s picture

This is awesome Karen, thanks for the speedy fix! I've checked the output and it works, thanks for adding the default dc:date too.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

natuk’s picture

Version: 7.x-2.x-dev » 7.x-2.6

Apologies for reopening this but I think it needs a bit more work. At the moment with the RDFx module one can assign properties to fields, so for example you get something like this:

<div class="field-items">
<div class="field-item even" datatype="xsd:dateTime" property="crm:P4F.has_time-span">
<span class="date-display-start" content="2012-10-15T00:00:00+01:00" datatype="xsd:dateTime" property="crm:P4F.has_time-span">Monday, 15 October, 2012</span>
to
<span class="date-display-end" content="2012-10-17T00:00:00+01:00" datatype="xsd:dateTime" property="crm:P4F.has_time-span">Wednesday, 17 October, 2012</span>
</div>
</div>

There is a problem here: the property crm:P4F.has_time-span of the field-item even is repeated in the date-display-start and the date-display-end spans, which is not semantically correct. One should be allowed to define separate properties for the two spans on top of what schema.org says. But is this an RDFx issue?