Attribute "itemscope" should define container for object, but currently is added as <meta> tag.
Proposed patch for microdata.module file in attachment.

Comments

ZDKia’s picture

We run into this issue and we modified microdata.module to include the patch code in 1947266 to corrected it as a workaround.

With a W3C HTML validator error of:
"Document type does not allow element "meta" here"
For which was showing errors referencing:

 <meta itemscope="" itemref="md1" />
         <meta itemscope="" itemref="md2" />

The microdata.module was modified to include the fix:
"Microdata for node are embedded incorrectly --- drupal.org/node/1947266
Attribute "itemscope" should define container for object, but currently is added as tag."

At this moment,
we need to address a similar error in a different HTML line.
Line 147, Column 106: there is no attribute "itemscope"
We still have the "itemscope" error but in a different line. the generated HTML shows:
<have the <div id="node-19" class="node node-article node-promoted node-sticky node-teaser clearfix" itemscope="">

Any suggestions?

Thanks!

jamsilver’s picture

StatusFileSize
new772 bytes

Rolling a patch in accordance with the guidelines.

Also, I'm not sure why the above patch was removing the meta tag declaring the node name, but it's not in my reroll.

jamsilver’s picture

StatusFileSize
new1.01 KB

Actually - here's a re-written version which conforms to Drupal's coding standards and doesn't throw a PHP Notice now and then.

Anonymous’s picture

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

I'm not sure what the problem is here that needs to be solved.

Any standards compliant microdata parser should be able to understand the following pattern:

  <span itemscope="" itemref="field-1"></span>
  <div id="field-1" itemprop="name">
    Title goes here
  </div>

You can test it at http://foolip.org/microdatajs/live/ or http://www.google.com/webmasters/tools/richsnippets, and you'll see that the properties are extracted as expected.

roderik’s picture

StatusFileSize
new4.35 KB

@ZDKia / #1: #1920400-12: Error: Element meta is missing required attribute content has now been incorporated into the -dev version, which should fix your problem. (A 'july-11' version should be appearing sometime; the 'july-10' version does not have this patch yet.)

@jamsilver / #2: the original patch was "removing the meta tag declaring the node name" skipping the output of all the 'node' elements, because the 'regular' microdata elements are already output in the node div. dr.user probably forgot that there are 'name' and 'url' meta tags too, which should be output in that place.
But if you completely skip that check, you're outputting the 'regular' metadata for the node twice, which is not a good idea.

I first thought this issue was a nice way of solving things. After all, if we are moving from 'meta' to 'span' tags anyway, why not move all the tags into the dedicated div for the node?

... well, these are the problems:

  1. You can't just 'skip outputting itemrefs' as all 3 uploaded patches do; it goes directly against the design of the module, which accomodates for 'fields not being inside the node div'. (See comments above microdata_item() )
  2. If you output all itemrefs, on the other hand, then HTML checkers will throw "duplicate item references" errors. (This is what the 3 above patches catch correctly.)

    So there is no way you can really do this correctly, in a generic way. Unless you start whipping up big and fine grained (and confusing) configuration methods.

  3. Also, if you go this route. the itemrefs you want for nodes that are e.g. in a view in a sidebar block, will not be complete. This is because
    • there are separate microdata meta tags for 'name' and 'url', whose itemrefs are generated on hook_page_process()
    • these meta tags must be output on hook_page_process() because it's the only 'generic' place where we can count on them being output. Node templates themselves do not have a $node['content'] variable that is present in standard templates.
    • The nodes in sidebars are usually already themed/rendered, before hook_page_process() runs.

I actually made a patch to catch point 3; generate all 'itemrefs' in hook_entity_load(), not hook_page_process(). It's at #2036819: Restructure microdata_item() storage

...but that was before I realized point 2 above :(

I'm uploading the work I did... which depends on #2036819: Restructure microdata_item() storage already being applied. It also does 'in-div output' for taxonomy terms and comments, besides nodes. But in hindsight, I agree with #4. There is no problem to solve here. And this patch will make HTML checkers output 'duplicate item references' errors.

roderik’s picture

Issue summary: View changes

Added missing info about patched file

summit’s picture

Issue summary: View changes

Hi,

Is there a way to remove the google errors related to

<meta itemscope="" itemref="md1" />
         <meta itemscope="" itemref="md2" />

I can't figure it out...
Thanks for your input in advance, greetings, Martijn