Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#33 | 1266688-33-microdata-support.patch | 8.79 KB | linclark |
#31 | 1266688-30-microdata-support.patch | 8.83 KB | linclark |
#28 | 1266688-28-date-microdata-support.patch | 9.11 KB | linclark |
#27 | date_microdata_support-1266688-27.patch | 9.78 KB | colette |
#21 | date_metadata_revert.patch | 7.62 KB | fago |
Comments
Comment #1
arlinsandbulte CreditAttribution: arlinsandbulte commentedPing...
Is this still valid? Are you still interested in supplying a patch for date?
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedI 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.
Comment #3
KarenS CreditAttribution: KarenS commentedIf 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 :)
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedSweet.... 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.Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedI'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.
Comment #6
KarenS CreditAttribution: KarenS commentedThe 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.
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commentedDo 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.
Comment #8
KarenS CreditAttribution: KarenS commentedfago (http://drupal.org/user/16747) wrote it, we would need to ask him what changes are safe to make.
Comment #9
Anonymous (not verified) CreditAttribution: Anonymous commentedI 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.
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedI 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.
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedAlso, this is the related issue where Entity Metadata integration was added.
#869606: integrate with the entity metadata module
Comment #12
arlinsandbulte CreditAttribution: arlinsandbulte commentedYeah, date tests take about 25 min on my local machine.
We could have the testbot take a stab at it....
Comment #14
KarenS CreditAttribution: KarenS commentedLooking 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.
Comment #15
KarenS CreditAttribution: KarenS commentedAll 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'])" ....
Comment #16
KarenS CreditAttribution: KarenS commentedI 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
Comment #17
rbayliss CreditAttribution: rbayliss commentedIt 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?
Comment #18
rbayliss CreditAttribution: rbayliss commentedForgot to use element_children().
Comment #19
rbayliss CreditAttribution: rbayliss commentedComment #20
Anonymous (not verified) CreditAttribution: Anonymous commentedI 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.
Comment #21
fagosry 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'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.
Comment #22
KarenS CreditAttribution: KarenS commentedYes, I will have to get this fixed and get out a new release.
Comment #23
KarenS CreditAttribution: KarenS commentedI 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.
Comment #24
KarenS CreditAttribution: KarenS commentedPosted 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.
Comment #25
magicmirror CreditAttribution: magicmirror commentedI'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.
Comment #26
scor CreditAttribution: scor commented@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.
Comment #27
colette CreditAttribution: colette commentedI 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.
Comment #28
Anonymous (not verified) CreditAttribution: Anonymous commentedI made a few modifications from the last patch.
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.
Comment #30
Anonymous (not verified) CreditAttribution: Anonymous commentedRemoving two pieces of offending code.
Otherwise, changes in #28 still apply.
Comment #31
Anonymous (not verified) CreditAttribution: Anonymous commentedGah, forgot to attach the patch.
Comment #33
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #34
botrisConfirming patch to work.
Comment #35
alexrayu CreditAttribution: alexrayu commentedConfirming the patch to work. Thanks Lin!
Comment #36
alexrayu CreditAttribution: alexrayu commentedComment #37
mobcdi CreditAttribution: mobcdi commentedHi 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
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?
Comment #38
Anonymous (not verified) CreditAttribution: Anonymous commentedTry 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.
Comment #39
mobcdi CreditAttribution: mobcdi commentedDo you mean the patch from #33 ?
Comment #40
webavant CreditAttribution: webavant commented#33: 1266688-33-microdata-support.patch queued for re-testing.
Comment #41
klonos...coming from #1103032: Document how to use date tokens
Comment #42
argol_0 CreditAttribution: argol_0 commentedI 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
Comment #43
cafuego CreditAttribution: cafuego commented#33: 1266688-33-microdata-support.patch queued for re-testing.
Comment #44
cafuego CreditAttribution: cafuego commentedApplied to 7.x-2.x-dev.
Comment #48
kyletaylored CreditAttribution: kyletaylored commentedSorry, 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.