getContents

Retrieves a list of published content from an enhanced CMS workspace or non-enhanced CMS workspace for an enhanced LWR site in Experience Cloud. This wire adapter can also retrieve published content from a non-enhanced CMS workspace for a non-enhanced LWR site.

To get Salesforce CMS content from an enhanced or non-enhanced CMS workspace for an Aura site, use the lightning/cmsDeliveryApi module’s listContent wire adapter instead.

Note

Syntax 

1import { LightningElement, api, wire } from "lwc";
2import { getContents } from "experience/cmsDeliveryApi";
3import siteId from "@salesforce/site/Id";
4
5export default class GetContentsCmsDeliveryApiV2 extends LightningElement {
6  @api contentKeys;
7
8  data;
9
10  @wire(getContents, { channelOrSiteId: siteId, contentKeys: "$contentKeys" })
11  onGetContents(result) {
12    if (result.data) {
13      this.data = result.data;
14    }
15  }
16}

User Interface API Resource 

With channelId parameter:

1GET /connect/cms/delivery/channels/${channelId}/contents

With siteId parameter:

1GET /connect/sites/${siteId}/cms/delivery/contents

getContent uses this CMS Delivery Contents Resource.

Parameters 

Parameter NameTypeDescriptionRequired?
channelOrSiteIdStringThe ID for the enhanced LWR site on which you want to use CMS content.Yes
contentKeysString[]The content keys for the CMS content that you want to use on your enhanced LWR site.
managedContentIdsString[]The managed content IDs for the CMS content that you want to use on your enhanced LWR site.
contentTypeFQNStringFully qualified name of the managed content type.
referenceDepthIntegerAn integer 0–3 specifying the depth of references.
pageIntegerNumber of the page you want returned. Starts at 0. If you don’t specify a value or if you specify 0, the first page is returned.
pageSizeIntegerSpecifies the number of items per page. Valid values are from 1 through 250. If unspecified, the default size is 25.
includeContentBodyBooleanSpecifies whether to return the content body (true) or summaries of references (false) in the response body. If unspecified, the default value is false.

Returns