QuickNav
Methods
- expandMacros(fieldValue) → {string}
- getInfo() → {ContentInfo}
- getItem(args) → {Promise}
- getItems(args) → {Promise}
- getLayoutInfo(args) → {Promise}
- getRenditionURL(args) → {string}
- getTaxonomies(params) → {Promise}
- loadContentLayout(args) → {Promise}
- queryItems(args) → {Promise}
- queryTaxonomyCategories(args) → {Promise}
- renderItem(args) → {Promise}
ContentDeliveryClient
Client object to interact with content published in Oracle Content Management:
- Read the published content items
- Render published content using named content layouts
Constructor
new ContentDeliveryClient(args) → {ContentDeliveryClient}
Parameters:
Name | Type | Description |
---|---|---|
args |
ClientParameters | A JavaScript object containing the parameters to create the content delivery client instance. |
Returns:
Methods
expandMacros(fieldValue) → {string}
Expand Content Macros.
Content item fields can contain macros that reference other content items. For example, a Rich Text field can have links to digital assets.
If a field that you want to render can contain macros, you can use this utility function to expand the macros. Expand macros are supported in Large Text fields, which work with rich text, but not in Text fields, which contain plain text. This method supports expanding the macro CEC_DIGITAL_ASSET into a rendition URL for a digital asset. If the asset GUID is followed by ",true" then the URL will be a download URL.
Content item fields can contain macros that reference other content items. For example, a Rich Text field can have links to digital assets.
If a field that you want to render can contain macros, you can use this utility function to expand the macros. Expand macros are supported in Large Text fields, which work with rich text, but not in Text fields, which contain plain text. This method supports expanding the macro CEC_DIGITAL_ASSET into a rendition URL for a digital asset. If the asset GUID is followed by ",true" then the URL will be a download URL.
Parameters:
Name | Type | Description |
---|---|---|
fieldValue |
string | A field value that may contain macros. |
Returns:
The "fieldValue" string with all macros expanded.
- Type
- string
Examples
// embed an image asset:
contentClient.expandMacros(
'<img src="[!--$CEC_DIGITAL_ASSET--]CONTABC123[/!--$CEC_DIGITAL_ASSET--]"/>');
// A download link:
contentClient.expandMacros(
'<a href="[!--$CEC_DIGITAL_ASSET--]CONTABC123,true[/!--$CEC_DIGITAL_ASSET--]">Download</a>');
getInfo() → {ContentInfo}
Retrieves the values stored as part of the client object and used on each call.
Once created, these values are immutable for the client instance.
Once created, these values are immutable for the client instance.
Returns:
The information the SDK is using to
retrieve content from Oracle Content Management.
- Type
- ContentInfo
Example
// get the information on the server and the state used by calls to this client
console.log(contentClient.getInfo());
getItem(args) → {Promise}
Get a single item given its ID or SLUG.
The ID can be found in the search results.
The ID can be found in the search results.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
object | A JavaScript object containing the "getItem" parameters.
Properties
|
Returns:
A JavaScript Promise object that can be used to retrieve
the data after the call has completed.
- Type
- Promise
Example
// Getting item by ID
contentPromise = contentClient.getItem({
'id': contentId
});
// Getting item by SLUG
contentPromise = contentClient.getItem({
'slug': contentSlug
});
// handle the result
contentPromise.then(
function (result) {
console.log(result);
},
function (error) {
console.log(error);
}
);
getItems(args) → {Promise}
Get a list of items based on their IDs.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
object | A JavaScript object containing the "getItems" parameters.
Properties
|
Returns:
A JavaScript Promise object that can be used to retrieve the
data after the call has completed.
- Type
- Promise
Examples
// get all items
contentClient.getItems().then(function (items) {
console.log(items);
});
// get all items and order by type and name
contentClient.getItems().then(function (data) {
// sort by type and then by name
console.log(data.items.sort(function (a, b) {
if (a.type.localeCompare(b.type) !== 0) {
return a.type.localeCompare(b.type);
} else {
return a.name.localeCompare(b.name);
}
}));
});
getLayoutInfo(args) → {Promise}
Retrieve metadata information about the content layout.
Note: This method isn't supported if the Content Delivery SDK is used in NodeJS.
Note: This method isn't supported if the Content Delivery SDK is used in NodeJS.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
args |
object | A JavaScript object containing the "getLayoutInfo" parameters.
Properties
|
Returns:
JavaScript Promise object that is resolved when the metadata for
the layout is retrieved.
- Type
- Promise
Example
// get the Content REST API versions supported by the content layout
contentClient.getLayoutInfo({
'layout': contentLayout
}).then(
function (layoutInfo) {
// determine the content versions supported by the layout
console.log('Content versions supported: ' + layoutInfo.contentVersion)
},
function (error) {
console.log('Error getting data: ' + error);
}
);
getRenditionURL(args) → {string}
Get the native URL to render an image asset.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
object | A JavaScript object containing the "getRenditionURL" parameters.
Properties
|
Returns:
A fully qualified URL to the published image asset.
- Type
- string
Examples
//get the native rendition URL for this client
contentClient.getRenditionURL({
id: 'CONTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1'
});
//get the Thumbnail rendition URL for an image in JPEG format
contentClient.getRenditionURL({
id: 'CONTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1',
type: 'Thumbnail',
format: 'jpg'
});
//get the native rendition URL, to be rendered inline
contentClient.getRenditionURL({
id: 'CONTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1',
download: false
});
//get the native rendition URL by slug, to be rendered inline
contentClient.getRenditionURL({
slug: 'pageBanner,
download: false
});
getTaxonomies(params) → {Promise}
Get taxonomies for the channel.
All arguments are passed through to the Content Delivery REST API call.
All arguments are passed through to the Content Delivery REST API call.
Parameters:
Name | Type | Description |
---|---|---|
params |
object | A JavaScript object containing the "getTaxonomies" parameters. |
Returns:
A JavaScript Promise object that can be used to retrieve
the data after the call has completed.
- Type
- Promise
Example
// get all taxonomies
client.getTaxonomies().then(function (topLevelItem) {
console.log(topLevelItem);
return topLevelItem;
}, function (xhr, status, error) {
console.log(xhr.responseText);
});
loadContentLayout(args) → {Promise}
Require in the requested content layout
Note: This method isn't supported if the Content Delivery SDK is used in NodeJS.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
args |
object | A JavaScript object containing the "renderItem" parameters.
Properties
|
Returns:
JavaScript Promise object that is resolved when the layout
JavaScript is loaded
- Type
- Promise
queryItems(args) → {Promise}
Get a list of items based on SCIM search criteria.
All arguments are passed through to the Content Delivery REST API call.
All arguments are passed through to the Content Delivery REST API call.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
object | A JavaScript object containing the "queryItems" parameters.
Properties
|
Returns:
A JavaScript Promise object that can be used to retrieve the data
after the call has completed.
- Type
- Promise
Example
// get all items and order by type and name
contentClient.queryItems({
'q': '(type eq "' + contentType + '")',
'fields': 'ALL'
}).then(function (items) {
console.log(items);
});
queryTaxonomyCategories(args) → {Promise}
Get categories for the specified taxonomy.
All arguments are passed through to the Content Delivery REST API call.
All arguments are passed through to the Content Delivery REST API call.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
args |
object | A JavaScript object containing the "queryTaxonomyCategories" parameters.
Properties
|
Returns:
A JavaScript Promise object that can be used to retrieve the
data after the call has completed.
- Type
- Promise
Example
// get all categories for a taxonomy
client.queryTaxonomyCategories({
'id': taxonomyId,
'q': '(name eq "' + categoryName + '")',
}).then(function (topLevelItem) {
console.log(topLevelItem);
return topLevelItem;
});
renderItem(args) → {Promise}
Render the given data or content item using the named layout in the given container.
Note: This method isn't supported if the Content Delivery SDK is used in NodeJS.
Note: This method isn't supported if the Content Delivery SDK is used in NodeJS.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
object | A JavaScript object containing the "renderItem" parameters.
Properties
|
Returns:
JavaScript Promise object that is resolved when the layout is
loaded and rendered into the container.
- Type
- Promise
Examples
// render the item into the DOM element with a custom content layout expecting data
compatible with Oracle Content Management Sites
contentClient.getItem({
'id': contentId
}).then(
function (contentItemData) {
// now the data is retrieved, render the layout
contentClient.renderItem({
'data': {
contentItemData: contentItemData,
scsData {
contentClient: contentClient
}
},
'layout': contentLayout,
'container': document.getElementById(containerDivId)
}).then(
function () {
// render complete
console.log('layout added to the page');
},
function (error) {
console.log('error rendering layout onto the page: ' + JSON.stringify(error));
}
);
},
function (error) {
console.log('Error getting data: ' + error);
}
);
// render the item into the DOM element with a custom content layout expecting custom data
contentClient.getItem({
'id': contentId
}).then(
function (data) {
// now the data is retrieved, render the layout
contentClient.renderItem({
'data': data,
'layout': contentLayout,
'container': document.getElementById(containerDivId)
}).then(
function () {
// render complete
console.log('layout added to the page');
},
function (error) {
console.log('error rendering layout onto the page: ' + JSON.stringify(error));
}
);
},
function (error) {
console.log('Error getting data: ' + error);
}
);