Importing related content became possible in dotCMS with the release of the 126.96.36.199 version. It is now possible to import content that is related to one or more contentlets that already exist in the system. Content can be related on import regardless of whether the relationship exists between two different structures or the structure is related to itself.
The video tutorial and documentation in the first example below shows how to import staff members and relate them to their pre-existing department(s) that they work in. This can now be achieved in a single import.
Two Related Content Structures
In the image shown below, a relationship has been created between two different content structures - Staff and Department. Several departments have already been created as content in the system.
Using the CSV file show below, staff members can be imported AND related to the department contentlets that already exist in the system. This is achieved by including an extra column that has the relationship name in the header and lucene queries in each row that match the department(s) that each staff member is a part of.
On import, dotCMS will read the lucene query in each row and relate one or many contentlets (in this case departments), to the staff members being imported. After the import, editing the staff content reveals the related department under the Relationships tab.
Importing Content to a Self-related Structure
When importing content with a self-join relationship, as in the example below, the header of the relationship column should indicate which side of the relationship the content should be imported from.
Importing CHILD Content: When -RELPARENT is appended to the end of the related content column header, then the results of the lucene query will be considered the parent content and the rows being imported will become their children.
Importing PARENT Content: When -RELCHILD is appended to the end of the related content column header, then the results of the lucene query will be considered the child content and the rows being imported will become their parents.
Special Note: If no option is appended to the header when importing self-related content, the -RELPARENT becomes the default and the content being imported is considered the child of the content pulled by the lucene in the relationship column.