Help topics

Link entries to other entries

A relation links an entry to one entry or many entries of another model, or of the same model. Editors pick the linked entries in the entry editor, and the API returns them with the entry.

Before you start

  • You need permission to update the model that will hold the relation. Linking changes that model. An administrator has this permission for every model.
  • The model you link to must be a model, not a component.

Add a relation to a model

Create the relation

  1. Select Models.
  2. Open the model that holds the relation.
  3. Select Add field.
  4. Select Relation.

Name the relation

  1. In Label, enter a name. Morphic fills API name from the label.
  2. Optional: In API name, enter another name. Use lowercase letters, digits and underscores, and start with a letter, such as author.
  1. Under Each {model name} links to, select one of these. The model name is in lower case, for example Each article links to:
    • One entry: each entry links to one entry.
    • Many entries: each entry links to several entries.
    • Entries of any model: each entry links to entries of any model.
  2. For One entry or Many entries, open Of model.
  3. Select the target model. To link to the same model, select the option that ends in (this model). Entries of any model has no Of model field.
  4. Optional: Turn off Must exist to allow links to entries that do not exist. It is on by default.
  5. Optional: For Many entries or Entries of any model, turn on Keep order. It remembers the order that editors choose.
  6. Select Add relation.

The relation appears in the model's field list with the badge Links to one or Links to many. Select it to change it.

To remove the relation, select Delete relation in the dialog.

Link entries in the entry editor

  1. Open an entry of the model that holds the relation in the entry editor.
  2. Under the relation, select Link. If the relation links to one entry and an entry is already linked, select Change instead.
  3. If the relation can link to more than one model, select the target model first.
  4. In Search…, enter text from the entry you want.
  5. Select the entry in the list.
  6. Select Save.

Result

Morphic saves the links when you save the entry. Each linked entry appears as a chip with its title. Select the title to open the linked entry. To remove a link, select Remove (x) on its chip, then select Save.

In the API, a relation is read through the edges endpoints:

  • GET /morphic/v1/edges/{id}/{relation} lists the links from an entry. Add ?dir=in to list the entries that link to it.
  • PUT /morphic/v1/edges/{source}/{relation}/{target} adds one link.
  • DELETE /morphic/v1/edges/{source}/{relation}/{target} removes one link.

To get linked entries inside an entry list, add ?relations=1 to the list request, or ?expand={relation} to expand one relation.

Errors

  • The API name uses lowercase letters, digits and underscores, like author: the API name does not match the rule. Change it and select Add relation again.
  • Choose which model it links to: select Of model, or select Entries of any model.
  • There is already a field called {name}: a field or relation in the model already has that API name. Choose another name.
  • {id} does not exist: the target entry was deleted or never existed, and Must exist is on. Choose an existing entry.
  • {relation} links to {allowed model}, not {model}: the target entry is from a model that the relation does not allow. Choose an entry from the model in Of model.