As I talked about in Microdata in Drupal: challenges for field formatters, microdata requires some specific code in field formatters for correct output. I will work on a patch to support this in Link.

I'm using the Entity Property API to find the parts that can be marked up, so the patch will depend on #1079782: support hook_entity_property_info()

Comments

Quarantine’s picture

Subscribing. Keep up the great work Lin!

dqd’s picture

Thanks Lin! Awesome!

... will be committed rapidly.

jherencia’s picture

colette’s picture

StatusFileSize
new9.02 KB

I wrote a patch fixing this issue as part of my Google Summer of Code project.

To test it, you can do the following:

  1. Add a link field
  2. Select the suggested mapping from the microdata "field properties" form field at the bottom
  3. Add a node
  4. Copy the source to http://foolip.org/microdatajs/live/ and check the JSON output for the microdata

Automated tests for this will be made available as part of the microdata module.

kim.pepper’s picture

Status: Active » Needs review
StatusFileSize
new9.2 KB

Re-rolled this against the latest 7.x-1.x branch.

I followed the steps as per above and can confirm it outputs valid microdata.

Kim

gittosj’s picture

Tested - seems to work perfectly

kim.pepper’s picture

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

bump

jcfiala’s picture

Status: Reviewed & tested by the community » Needs work

Close, but not quite.

When I turned all this on and applied the patch, then link fields with a Title but no url come out as <span >TEXT</span>, which sort of breaks things.

jcfiala’s picture

Issue summary: View changes

Changed issue reference.

klonos’s picture

Issue summary: View changes
Issue tags: +Needs reroll
patching file link.info
Hunk #1 succeeded at 5 with fuzz 2 (offset -1 lines).
patching file link.microdata.inc
patching file link.module
Hunk #1 FAILED at 877.
Hunk #2 succeeded at 916 (offset 26 lines).
Hunk #3 succeeded at 936 (offset 25 lines).
Hunk #4 FAILED at 928.
Hunk #5 succeeded at 968 (offset 23 lines).
Hunk #6 succeeded at 999 with fuzz 1 (offset 23 lines).
Hunk #7 succeeded at 1035 with fuzz 1 (offset 23 lines).
Hunk #8 succeeded at 1057 with fuzz 1 (offset 22 lines).
Hunk #9 FAILED at 1046.
Hunk #10 FAILED at 1303.
Hunk #11 succeeded at 1365 (offset 32 lines).
4 out of 11 hunks FAILED -- saving rejects to file link.module.rej
kim.pepper’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new8.47 KB

Re-roll

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #11 applies cleanly against the current dev, & enables the desired functionality.

The problem mentioned at #9 did not present itself. The link field appears to require setting a URL whenever setting a title, & setting a title mapping with no URL mapping in the Microdata settings for the link field caused no problems either, in case that was what was meant.

RTBC.

The last submitted patch, 5: 1267662-5-link_microdata_support.patch, failed testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 11: 1267662-microdata-11.patch, failed testing.

Anonymous’s picture

Yes it does need work. After my post I discovered that this patch causes an undefined index warning.

Notice: Undefined index: microdata in theme_link_formatter_link_default() (line 1008 of /site/sites/all/modules/link/link.module).

theme_link_formatter_link_default() has the following:

$microdata = $vars['microdata'];

But there is no microdata variable in the $vars array.

I further found that I could modify

'link_formatter_link_default' => array(
      'variables' => array('element' => NULL, 'field' => NULL, 'microdata' => NULL),
    ),

in link_theme() to get microdata into $vars, but it remains null.