Relationships

This is a quick tutorial on how to import into Playa or Relationship fields

The first import

Firstly, we’ll import our initial set of data into the News channel. Here we are using a CSV file called dummy.csv.

Configure the import

We’ll just fo a simple import, setting the Title, Entry Date and Body fields of the entry

Results of the first import

We now have 3 new entries in the News channel.

The second import

In this import we’ll use an XML file called dummy.xml. We want to relate these entries to the entries we have just imported (using the relationship field), so the entries in this file all have a field that contains the titles of the entries that they should be related too (eg, Two)

Configure the second import

As with the first we have set up a simple import, but with the addition of the relationship field.

In the relationship field we choose which field in the data source describes the relationship. In this case the field ‘related/title’ contains the name(s) of the titles from the first import.

Note that you can use another field other than the entry’s title to match on. You could use the entry’s id or another custom field if that is a better option (eg, a Product’s unique identifier)

The final results

When we run the second import it creates new entries and adds any relationships it finds.

If you are importing entries and want to assign multiple related entries to it, you can pass a pipe delimited string of entry IDs for each relationship to create. For example if 3|10|23 is the value of one of the CSV columns, JSON or XML nodes, and you mapped that field to a Relationship field in ExpressionEngine, then the imported entry will be assigned 3, 10, and 23 assigned as a relationship.

Last updated