6

I am trying to migrate a link field field_url from a Drupal 7 site to my Drupal 8 one. The link field is compound, it has a title and a url value. In my process plugin I am selecting the right values (field_url_title and field_url_url), but I don't know how to map them in my yaml definition file. What I have:

          field_url: field_url_url
          field_url_title: field_url_title

...maps correctly the url, but does not populate the title one. What's the destination field machine name I would need to use to add in the link title?

4 Answers 4

9

Here is an example:

field_url:
  plugin: iterator
  source: field_url
  process:
    uri: url
    title: title
    options: attributes

Because in D8 the field_url_url database field changed to field_url_uri and the attributes to options, you can not use direct mapping on this field.

5

As of Drupal 8.4, the iterator process plugin is deprecated. Use sub_process instead

See change record: https://www.drupal.org/node/2880427

field_url:
  plugin: sub_process
  source: field_url
  process:
    uri: url
    title: title
    options: attributes
4

As of at least 8.4, the "field_link" plugin should do the trick. https://api.drupal.org/api/drupal/core%21modules%21link%21src%21Plugin%21migrate%21process%21FieldLink.php/class/FieldLink/8.4.x

process:
  field_new_link_field:
    plugin: field_link
    uri_scheme: 'https://'
    source: field_source_link_field
4

If you just want to migrate a link and title from source fields to link fields this should work.

  'field_web_link/uri': link
  'field_web_link/title': title

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.