It would be really great if one could assign schema.org or RDFa tags to the components, either individually (lastName for the last name component, or grouped (name for the full field).

Comments

alan d.’s picture

Category: Feature request » Task

Since there is already code to allow SPAN classes through the formatter, this should not be too difficult (hopefully)

General wrapper could be similar to:

<div itemscope itemtype="http://schema.org/Person">
  <span itemprop="name">Jane Doe</span>
</div>

Or individual components.

givenName Text Given name. In the U.S., the first name of a Person. This can be used along with familyName instead of the Name property.
additionalName Text An additional name for a Person, can be used for a middle name.
familyName Text Family name. In the U.S., the last name of an Person. This can be used along with givenName instead of the Name property.
honorificPrefix Text An honorific prefix preceding a Person's name such as Dr/Mrs/Mr.
honorificSuffix Text An honorific suffix preceding a Person's name such as M.D. /PhD/MSCSW.

Does not appear to use generational suffix

<div itemscope itemtype="http://schema.org/Person">

I guess this should be an optional wrapper, name is just one component of a Person

alan d.’s picture

Version: 7.x-1.9 » 8.x-1.x-dev
alan d.’s picture

Category: Task » Feature request
Status: Active » Needs review
StatusFileSize
new13.59 KB

So RDFa support is inbuilt into core.

<article typeof="schema:Person">

And the module Schema.org configuration tool (RDF UI) can allow you to add the property="type:name"

https://www.drupal.org/project/rdfui

That leaves the components themselves, (if required). So added field formatter support for:

  • No markup: Aaa Bbb
  • Component classes: class="COMPONENT"
  • Microdata itemprop components: itemprop="KEY" class="COMPONENT"
  • RDFa property components: property="schema:KEY" class="COMPONENT"

Complete mapping wasn't possible using schema:Person Name, aka there isn't direct support for the preferred or generational suffix (albeit the latter could be part of the family name...)

Key map follows:

    $map = [
      'title' => 'honorificPrefix',
      'given' => 'givenName',
      'middle' => 'additionalName',
      'family' => 'familyName',
      'credential' => 'honorificSuffix',
      'alternative' => 'alternateName',
    ];

The existing Markup formatter option was hijacked for this role.

The Output formatter option was dropped in the process of this patch.

The NameParser and NameFormatter now returns a Formattable object (\Drupal\Component\Render\MarkupInterface), rather than a potentially mixed string or MarkupInterface object.

  • Alan D. committed e71e1eb on 8.x-1.x
    Issue #2204387 by Alan D.: RDFa/Schema.org support
    
alan d.’s picture

Status: Needs review » Fixed

Probably not enough interest to backport :/

Status: Fixed » Closed (fixed)

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