Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
To support microdata, field formatters need to add the attributes directly. I will upload a patch that works for the current microdata API.
Comment | File | Size | Author |
---|---|---|---|
#29 | support_microdata-1259582-24.patch | 13.51 KB | nonAlgebraic |
#28 | weblinks_address_microdata.jpg | 130.16 KB | Summit |
#23 | support_microdata-1259582-23.patch | 13.85 KB | Anonymous (not verified) |
#21 | support_microdata-1259582-21.patch | 14.71 KB | Anonymous (not verified) |
#20 | support_microdata-1259582-20.patch | 15.03 KB | Anonymous (not verified) |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #2
Damien Tournoud CreditAttribution: Damien Tournoud commentedThanks for this! But which version of this module has you used as the basis of this patch? We don't have any template anymore in the module since the big refactoring that happened back in June.
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedoh whoops.... I hadn't updated my code since early June.
I'll have to do a git pull and get it working again. Thanks!
Comment #4
scor CreditAttribution: scor commentedis there any way we can make the default mappings more generic so that they can not only be used for microdata for also for RDFa and RDF in general?
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedThat's not so much an issue with AddressField as it is with microdata's hooks. I'd suggest posting it on the MD queue.
Comment #6
scor CreditAttribution: scor commentedI'm not sure I expressed myself properly. the actual default mappings are good and make sense for the addressfield module. What I was talking about is the hook in which they are defined. what I'd rather see is something like hook_rdf_field_defaults() where these mappings are defined, so that any module interested in these mappings such as microdata and RDFx (RDF UI) can leverage these. but in any case I'll bring up this in the MD queue which is more appropriate to discuss this. thanks for working on this Lin!
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commentedThis patch:
addressfield_field_formatter_view
passes it to the format plugins using the context variable._addressfield_get_attributes
) to process the class attributes and microdata attributes into a single attributes array for each property.Note: in the original name_oneline formatter, the class name-block was used instead of name-oneline, which makes it the only class that doesn't match the property name. I'm not sure if that was intentional or not. This patch changes it to name-oneline.
In order to test this:
The way I insert the microdata into context and then use it in the format plugins might not be the best. Also, open to suggestions for the microdata API if you have any thoughts on how to make it easier for field formatter developers.
Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commentedI updated the patch due to #1278200: Add hook_microdata_value_type_alter.
This patch does everything in #8. It also:
Comment #9
klonosUsing latest dev versions of core, Address Field, Microdata and required modules, when I edit a "Postal address" field (provided by Address Field) I get this error:
Notice: Undefined index: #value_type in microdata_get_instance_mapping_form() (line 174 of /var/www/my-site/sites/all/modules/microdata/microdata.admin.inc).
I have applied the patch in #8
Comment #10
rbayliss CreditAttribution: rbayliss commentedIt looks like hook_microdata_value_type_alter has been renamed to hook_microdata_value_types_alter(). Also, the previous patch doesn't alter the administrative area field. Note that this patch changes the class of this field from state to administrative-area.
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedThis brings the patch up to date, and I will likely be moving into RC soon.
Any thoughts from the maintainers on how likely a commit is?
Comment #12
gittosj CreditAttribution: gittosj commentedTested and works perfectly - thank you and great work!
Comment #13
pinkonomy CreditAttribution: pinkonomy commentedDoes this patch also support schema.org ?
Comment #14
randallknutson CreditAttribution: randallknutson commentedUpdating so it will apply to latest 1.0-beta4
Comment #15
dr.user CreditAttribution: dr.user commentedPatch #14 works for me.
Comment #16
johnvIt seems this pach is now outdated, since the last months some patches/modules have been published:
Schema_org module supports Addressfield
#797912: Rich Snippets integration
Comment #17
bojanz CreditAttribution: bojanz commented@linclark
Given #16, is the patch in this issue still relevant?
Comment #18
Mac_Weber CreditAttribution: Mac_Weber commented@bojanz I think you maintainers could recommend the Schema_org module at the AddressField main page and close both this issue and also:
#797912: Rich Snippets integration
Comment #19
Anonymous (not verified) CreditAttribution: Anonymous commentedHere is a patch which applies against the latest dev & successfully adds Microdata support to Addressfield. It validates at https://developers.google.com/structured-data/testing-tool/ . Please review.
This allows those of us who use the Microdata module rather than the Schema.org module to have microdata on our address fields. Reasons to run Microdata include handling of certain Panels issues & a preference for microdata over RDFa 1.0 (used by Schema.org); microdata is the format recommended by Google.
Comment #20
Anonymous (not verified) CreditAttribution: Anonymous commentedAnd here is the patch.
Comment #21
Anonymous (not verified) CreditAttribution: Anonymous commentedDisregard the last patch, it had a typo that broke this:
$format['locality_block']['#attached']['css'][] = drupal_get_path('module', 'addressfield') . '/addressfield.css';
The version attached here corrects that.
Comment #22
Manuel Garcia CreditAttribution: Manuel Garcia commentedHey, thanks for taking this on! Here is a quick review:
This shouldnt be here... it looks like you built the patch on the dev tarball? Please checkout the repo using git to build the patch.
Same as above.
Comment #23
Anonymous (not verified) CreditAttribution: Anonymous commentedGood catch, that is what happened. New patch minus the tarball packaging info. Also one further change: In the Microdata module,
hook_microdata_field_defaults
was replaced withhook_microdata_suggestions
, so this patch makes that change as well (the previous one didn't).Comment #24
JayShoe CreditAttribution: JayShoe commentedHello,
I wanted to post to say that this patch has worked for me. I am using core, Panels, Microdata, and addressfield and have it working and configured to validate through the Structured Data Testing Tool.
I hope this gets committed. It's been 3 months since this patch has been here, and the microdata module looks a little stale as well. I tried both microdata and schemaorg and the microdata/addressfield combination is by far superior. Especially since the schemaorg implementation doesn't support panels.
How I made it work.
I will note that the Use Suggested Microdata Mappings option towards the bottom of the field edit page did not work for me. I'm building a www.schema.org/LocalBusiness with an Address and I had to configure it as the following.
- Address Microdata Mapping>Field property(s) = "address"
- Check off the option to Handle as an item in microdata> Item Type = http://schema.org/PostalAddress
- Then the properties of the address need to be matched accordingly.
I used the http://www.microdatagenerator.com/ tool to create a valid schema.org/LocalBusiness listing and then copied the properties from that.
Comment #25
JayShoe CreditAttribution: JayShoe commentedI just wanted to update that this configuration works.
- ctools-7.x-1.7+18-dev
- panels-7.x.3.5
- addressfield-7.x-1.1+3-dev + patch #23
- microdata-7.x-1.0-beta2
I was unable to get it to work with ctools-7.x-1.7 (non dev version) and microdata-7.x-1.0-beta2 is the recommended version as of today because they won't go official release until there is enough support. Get this patch committed to move this support along.
Comment #26
daemonchrist CreditAttribution: daemonchrist commentedThis is almost, but not quite working. The field edit page now shows boxes to map Country, Administrative area, Locality, etc., but not the boxes for Field property(s), Handle as an item, or Item Type.
Comment #27
jenlamptonLooks like @daemonchrist meant to set this to NW.
Comment #28
Summit CreditAttribution: Summit commentedHi,
I added this patch, thanks!
And it only worked when I changed my own content type to a http://schema.org/Address type. Within the Microdata TAB on /admin/structure/types/manage/[CONTENTTYPE] In my case Weblinks contenttype.
Now on admin/structure/types/manage/[CONTENTTYPE]/fields/field_adresI see the Microdata form arising, Yes.
But what to fill in (It is dutch)? And how to get it validated by Google Structured Data?
Thanks for your reply in advance,
Greetings, Martijn
Comment #29
nonAlgebraic CreditAttribution: nonAlgebraic commentedJust making patch #23 work on the latest release (7.x-1.2).
Comment #30
Summit CreditAttribution: Summit commentedHi, trying this patch, and I think it needs something like this added: https://www.drupal.org/files/issues/microdata_non_existent_identifier-24...
While I got all kinds of MD1, MD2 errors like on that issue https://www.drupal.org/project/microdata/issues/2449861
greetings, Martijn