Mapping fields

Last updated on
4 October 2018

You can specify a mapping to each property of a field to an external data key. Additionally, consider the following data being returned by an external source:

{
  id: 123,
  title: 'Drupal',
  contact_information: {
    telephone_number: '+123456789',
	email_address: 'test@test.com',
	website: 'https://www.drupal.org'
  }
}

To get the data in the structure you can use a forward slash (/) notation. If in the example above you want to map to the email address, you would use the "contact_information/email_address" notation. Mapping to multivalued values is possible as well using the asterisk (*) notation. If "contact_information" in the example above was an array of contact information values, mapping to the multiple email addresses can be done with the following notation: "contact_information/*/email_address".

Furthermore, instead of mapping to a value returned by the external source, you can also provide a static value instead. In conjunction with the property based mapping, this can be useful for mapping formatted text fields, where you can configure which text format should be used for the mapped value. Static values can be entered by prefixing it with a plus (+) character (eg. "+basic_html").

You can also subscribe to events for mapping external data to Drupal fields (and vice versa) for when you need to apply some very specific custom logic (eg. see \Drupal\external_entities\Event\ExternalEntitiesEvents).

External images

To display external images, you can map the external image address to a link field and use the module Imagecache External to set the display format of this link field to 'Imagecache External Image' with the original image or one of the image styles available in Drupal.

Help improve this page

Page status: No known problems

You can: