Problem/Motivation

Schema.org doesn't recognize the itemid as being the same as identifying the url with their schema:url. I've posted an issue to their forum, but it's unlikely to get a response any time soon.

In the meantime, there should be a way to get a schema:url output for items.

Proposed resolution

Provide an option with the item options which allows users to add a schema:url for items.

User interface changes

Checkbox option.

API changes

Flag on any item in API.

Comments

Anonymous’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

jaguero’s picture

When I used the updated patch, I noticed an issue.

$entity_uri['path'] only prints the node/NID which results in http://example.com/path/path/node/nid, instead of http://example.com/node/nid.

I added 2 adjustments to the code:

  1. Check if the $entity_uri['path'] has an alias, if yes then override variable with path alias
  2. added trailing slash before the url

Starts at line 1047

/**
 * Helper function.
 *
 * Gets an array of attributes for the Schema URL.
 *
 * @todo Remove this function once Google recognizes itemid.
 */
function _microdata_get_schema_url($entity_type, $entity) {
+  $entity_path = '';
  $entity_uri = entity_uri($entity_type, $entity);
+  $entity_path = drupal_get_path_alias(($entity_uri['path']), NULL);

+  if(!empty($entity_path)) {
+  	$entity_uri = $entity_path;
+   }
  return array(
    '#attributes' => array(
-      'href' => $entity_uri['path'],
+     'href' => isset($entity_path) ? '/'.$entity_uri : '/'.$entity_uri['path'],
      'itemprop' => 'url',
    ),
  );
}

Thank you,
Jorge
http://www.jorgeaguero.me