I made the best effort I could to understand how to incorporate microdata into the Date module.

I can help with this. The API isn't frozen yet and I'm using AddressField as my compound field test formatter, so it won't be for a while. Once I have the API in relatively stable shape and the AddressField patch ready for commit, I will work on a patch for Date field.

If you have any other questions, feel free to post an issue in the microdata queue or post in this queue and ping me.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

arlinsandbulte’s picture

Status: Active » Postponed (maintainer needs more info)

Ping...
Is this still valid? Are you still interested in supplying a patch for date?

Anonymous’s picture

I can help get this going if you are interested. I could provide code and some SimpleTests to ensure that it continues to work as changes to Date module are added. I haven't looked at what is entailed with the field formatters, but I could write the code for at least one, and potentially all of them depending on how much time it takes.

Because each field formatter needs to have microdata, I can't commit to long-term maintenance for anything besides the fields provided in core. While I may be available to advise if any additions or fixes are necessary later, I also might not be able to help.

If that works for the maintainers of Date, then we can move it back to active.

KarenS’s picture

Status: Postponed (maintainer needs more info) » Active

If you could provide the initial code so we can see what you think is necessary, that is the most helpful thing you can do. You don't have to be on the hook to maintain it in perpetuity :)

Anonymous’s picture

Sweet.... perpetuity is such a very long time ;)

I've started working on this and have basic integration for single dates.

One thing that I will need to resolve is the tag to use. Since Microdata is a part of the HTML5 spec, it relies on some HTML5 tags. Microdata doesn't parse the content attribute from a <span> tag. Instead, I could use the <time> tag, or the invisible <data> or <meta> tags would suffice.

Is there any interest in switching the HTML output to use the <time> tag? This tag has been added as a theme function to Drupal 8, but isn't yet a part of D7 core.

Anonymous’s picture

I'm attaching a patch that adds basic support for just the single date theme function.

NOTE: this patch isn't ready to commit. I commented out an if statement in date_entity_metadata_property_info_alter() because I need some data from the Entity Property API definition (the 'type' key and the 'microdata' key which I added). Is the if statement around the property info array necessary?

This patch still needs work before it outputs all of the microdata needed. In addition, I plan to add a test and also some default microdata settings for Schema.org to the patch.

KarenS’s picture

The code for date_entity_metadata_property_info_alter() was contributed by fago to make Rules work. I don't understand it well enough to be sure why it is there.

Anonymous’s picture

Do you have the issue number or know who wrote that bit of code? It should be fine (even preferable) to move part of that block outside the if statement, but I want to make sure I'm not missing something.

KarenS’s picture

fago (http://drupal.org/user/16747) wrote it, we would need to ask him what changes are safe to make.

Anonymous’s picture

I asked klausi about this in IRC, he said that if he remembered correctly, all dates have a 'todate' value. However, as he pointed out, this checks the settings, not the value, so I'm not sure that was the reason the if statement was put in there. I'll see if I can find fago.

Anonymous’s picture

I couldn't manage to get a hold of fago, but I've added the changes that I think should be made to the Entity API integration.

This could impact Rules, so I will need someone to test and ensure that it still works. I tried running all the automated tests, but it was taking a really long time and I don't know whether there is test coverage for the Rules integration. There are currently notices in the tests, I will resolve that before the patch moves close to RTBC.

Anonymous’s picture

Also, this is the related issue where Entity Metadata integration was added.

#869606: integrate with the entity metadata module

arlinsandbulte’s picture

Status: Active » Needs review

Yeah, date tests take about 25 min on my local machine.
We could have the testbot take a stab at it....

Status: Needs review » Needs work

The last submitted patch, 1266688-10-support-microdata.patch, failed testing.

KarenS’s picture

Looking at this more closely, it looks like it mainly adds new information to the metadata, which I assume won't be a problem. I can try the tests locally. Is there anything else important that needs to go into this? I want to roll a new release and try to get this in.

KarenS’s picture

All the failures are undefined index notices for the new variables. I think the culprit is this, which is not doing "if (!empty($variables['add_microdata'])" ....

+  // If Microdata is enabled, pass the microdata attributes for this field down
+  // to the theme.
+  if ($variables['add_microdata'] && isset($entity->microdata[$field['field_name']])) {
+    $variables['microdata'] = $microdata = $entity->microdata[$field['field_name']]; 
+  }
KarenS’s picture

Status: Needs work » Postponed (maintainer needs more info)

I fixed the things causing notices and committed this. Is it right that only the start date is picking up microdata? Just confirming that.

http://drupalcode.org/project/date.git/commit/ab5d593

rbayliss’s picture

It looks like the end date and duration are missing theme function support, and being enabled in date_entity_metadata_property_info_alter(). Here's a patch adding it in. I wasn't sure what to do about duration (which will need to be calculated). Does the API provide a way to grab an ISO duration?

rbayliss’s picture

Forgot to use element_children().

rbayliss’s picture

Status: Postponed (maintainer needs more info) » Needs review
Anonymous’s picture

I must have missed this commit in my tracker. I never set the patch to needs review myself because it wasn't ready for commit.

After talking with Fago at DrupalCon, it became clear that my alteration to the Entity Property API went against his design of the Rules integration here. I would recommend that the commit be reverted and that we continue to work on this in patch form until it is ready for commit.

fago’s picture

FileSize
7.62 KB

sry for coming late to the party!

Yep, as I explained to linclark the previous behavior of only creating a data structure containing sub-properties (start-date, end-date, duration) if required was intentional. It avoids unnecessary nesting and so keeps things more simple for users. But moreover changing that now breaks people's Rules, tokens, search-api-searches .. - everything that makes use of it. :/ E.g. #1522018: Missing feature fields causes rules data set errors.

I would recommend that the commit be reverted and that we continue to work on this in patch form until it is ready for commit.

I'd second that. It's a pity to have it in a release though, I guess it would be good to roll out a reverted release asap. Patch attached.

Update: Maybe we should work on adding tests for that. It can be easily verified to work correctly by using the entity metadata wrappers with a date field.

KarenS’s picture

Yes, I will have to get this fixed and get out a new release.

KarenS’s picture

Status: Needs review » Needs work

I committed the patch in #21, and I got some tokens back. But I'm not seeing all of them. Not sure why that is except there were some other issues about only some tokens working and maybe we're back to that now. But that should be a different issue.

KarenS’s picture

Posted an issue about the broken Entity Tokens at #1530042: Get Entity Tokens working. From this point on let's keep this issue to discussions about microdata.

magicmirror’s picture

I've spent an entire day trying to use the SchemaOrg module to tag the startDate and endDates with this module. Having read several of these postings, I'm still unclear if it is fixed and the problem is on my end, or if it is not fixed and the team is still trying.

Other threads and users seem to be doing what I'm trying to do, but I'm at the end of my technical knowledge at this point. Maybe too long in the saddle today, but any feedback you've got would be very appreciated! Thanks team.

scor’s picture

@magicmirror: SchemaOrg supports the RDFa syntax. microdata is another syntax which has its own module: http://drupal.org/project/microdata

This issue is specifically about microdata support in the date module. If you have questions about the schema.org module specifically, please file a support request in this issue queue: http://drupal.org/project/issues/schemaorg - date should work with schema.org though.

colette’s picture

I wrote a patch with added microdata support for the range display of dates (i.e. start date and end date together), and for the duration display.

Anonymous’s picture

Status: Needs work » Needs review
FileSize
9.11 KB

I made a few modifications from the last patch.

  • Fixed the UI so it shows up for both single dates and range dates. This required a fix in microdata module, so will only work with latest dev.
  • Put a little logic in the date_single preprocess function to handle the difference in data structure between single dates and range dates.
  • Removed duration/interval handling because I'm not sure how those two work in date module. It's less likely that someone will need that, so I'd say just leave it out for the first patch. If there is an issue requesting it later, then I can help with that then.

As far as I'm concerned, this is ready now. It shouldn't affect Rules at all and I have tests for it in the microdata module.

Status: Needs review » Needs work

The last submitted patch, 1266688-28-date-microdata-support.patch, failed testing.

Anonymous’s picture

Status: Needs work » Needs review

Removing two pieces of offending code.

Otherwise, changes in #28 still apply.

Anonymous’s picture

Gah, forgot to attach the patch.

Status: Needs review » Needs work

The last submitted patch, 1266688-30-microdata-support.patch, failed testing.

Anonymous’s picture

Status: Needs work » Needs review
FileSize
8.79 KB
botris’s picture

Confirming patch to work.

alexrayu’s picture

Confirming the patch to work. Thanks Lin!

alexrayu’s picture

Status: Needs review » Reviewed & tested by the community
mobcdi’s picture

Hi all

I'm trying to tag a content type with microdata using the Event schema but my date field doesn't allow me specify whether its a start or end date it just shows

Event date Microdata Mapping
Event uses the itemtype http://schema.org/Event.

I have the Date field configured to collect an end date but its not required

In the other fields i can specify which schema property I want mapped to that field.

Running a sample node through the google structured data testing tool shows
Warning: Missing required field "dtstart".
Which is strange because the schema.org/Event doesn't have dtstart that I can see.

The rdfa output shows the startTime and endtime are filled for the sample node

Is is something to worry about?

Anonymous’s picture

Try applying this patch and clearing your caches. This will make the interface for microdata work.

You probably don't want to use microdata and RDFa at the same time.

mobcdi’s picture

Do you mean the patch from #33 ?

webavant’s picture

#33: 1266688-33-microdata-support.patch queued for re-testing.

klonos’s picture

argol_0’s picture

I have the same problem as #37, applying the patch #33 shows these warnings:

Notice: Undefined index: microdata en microdata_form_field_ui_field_edit_form_submit() (línea 242 de /home/website/public_html/sites/all/modules/microdata/includes/microdata.form_alter.inc).
Warning: Invalid argument supplied for foreach() en microdata_form_field_ui_field_edit_form_submit() (línea 242 de /home/website/public_html/sites/all/modules/microdata/includes/microdata.form_alter.inc).

I'm using drupal 7 and date 7.x-2.6

cafuego’s picture

#33: 1266688-33-microdata-support.patch queued for re-testing.

cafuego’s picture

Status: Reviewed & tested by the community » Fixed

Applied to 7.x-2.x-dev.

Status: Fixed » Closed (fixed)

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

Status: Closed (fixed) » Needs review

Status: Needs review » Needs work

The last submitted patch, 33: 1266688-33-microdata-support.patch, failed testing.

kyletaylored’s picture

Issue summary: View changes
Status: Needs work » Closed (fixed)

Sorry, was checking patch status for drush make file and release log said it was reverted, twice. Just needed to confirm, but now I see it's actually been committed despite the change log.