Skip to main content

An entry can link to other entries or assets as entry, asset or image field types. They can be defined as a standard entry field or as a composed field type in the content type. These links can be singular or multiples of the same content type e.g. Actor, Image, etc.

Linked content can be unresolved or resolved depending on whether a linkDepth value has been provided when retrieving entries using the get, list or search methods.

Unresolved entries

An unresolved entry or asset is essentially a subset of the entry structure with enough information to get the correct entry language variation. A subsequent service call is required to obtain the linked content. Unresolved entries and assets is the default behaviour for linked content.

Resolved entries

Entries can be resolved automatically in the service to a maximum depth of 10 using the linkDepth parameter in any retrieval operation. Resolving entries in a single call can significantly improve the render performance of your webpage or application. Whilst fewer network requests can be beneficial, it can also be detrimental if the linkDepth is too deep, or if there are many linked fields.

Field-specific link depths:

From version 16 of Contensis onwards, if you want to specify link depths for individual fields, you can specify the fieldLinkDepths parameter on all Delivery API methods that retrieve entries. This is a simple object containing field paths and link depth values. Matching field paths override the link depth and where more than one field path matches a field, the most specific (longest) is used. The example below will resolve to a link depth of 1 for all fields, except for the composer field which is resolved to a link depth of 2, though the entryLink field in a linkedEntryComponent in that composer is overridden to return to a link depth of 1.

JavaScript
const query = new Query(
    Op.contains('title', 'batman'),
    Op.greaterThan('runtime', 200)
);
query.fieldLinkDepths = {
    composer: 2,
    'composer.linkedEntryComponent.entryLink': 1
};

ContensisClient.entries
  .search(query, 1)
  .then(function (pagedResult) {
      console.log(pagedResult.totalCount);
      console.log(pagedResult.items);
  });

Resolution rules

When a linked entry is accessed then the following rules apply:

  • If a language has been specified in the link, then the specific language variation will be returned.
  • If a language has been specified in the link, but the specific language variation does not exist, then null will be returned or will not be included in the array.
  • If a language has not been specified, then the defaultLanguage value defined in the content type will be used to select the appropriate entry variation to return.
  • If a language has not been specified and there is no default variation, then null will be returned.

Example

JavaScript
resolve(entry: Entry, fields?: string[]): Promise<Entry>;
resolve(entryArray: Entry[], fields?: string[]): Promise<Entry[]>;
resolve(pageListOfEntries: PagedList<Entry>, fields?: string[]): Promise<PagedList<Entry>>;

ContensisClient.entries.get('<entry_id>').then(function (entry) {
    console.log(ContensisClient.entries.resolve(entry));
});

ContensisClient.entries.list('<content_type_id>').then(function (entryList) {
  entryList.items.forEach(item => (
    console.log(ContensisClient.entries.resolve(item))
   ))
});

Still need help?

If you still need help after reading this article, don't hesitate to reach out to the Contensis community on Slack or raise a support ticket to get help from our team.
New support request