Bridgeline Digital Logo
Menu

Rendering API

The OrchestraCMS Rendering API is used to get rendered OrchestraCMS content and pages based on certain criteria. It returns the latest version of content appropriate to the OrchestraCMS runtime context (i.e. Preview vs. Production). It can be accessed via a JavaScript, Apex or REST interface.

There are twelve supporting classes needed for the Rendering API in order to return a RenderResultBundle for use. These helper classes are available in the API 5.0 Resources and the required classes are JSONMessage, APIRequest, RenderingAPIRequest, SocialActivity, SocialBundle, ContentTypeBundle, AttributeBundle, ContentLayoutBundle, TargetBundle, TaxonomyBundle, ContentBundle and RenderResultBundle

 

The included examples System.Debug(apiResponse.responseObject) statements output a RenderResultBundle. For more information on the APIResponse object, please see the APIResponseObject documentation

getRenderedContent (by Content Name)

This method provides rendered content based on the provided parameters. There are four available options for content retrieval. Possible values are "contentName", "contentType", "originId", and "taxonomy". The following table outlines the required and optional parameters for each of the four methods.

To getRenderedContent by Content Name, use a string value of 'contentName' for the renderType parameter.

Parameters

  • renderType : StringMethod of content retrieval. Must be set to 'contentName' to getRenderedContent by Content Name.
  • status : String (optional; default: 'all'), Used to specify whether published, unpublished, or both will be returned. This value is ignored in production mode. Accepted String values are:
    • all - retrieves both published and unpublished content.
    • published - retrieves only published content.
    • unpublished - retrieves only unpublished content.

List Parameters

  • contentNamesList<String>, The content names to search for. Can be the name of the content in any of its translated languages.

Apex Request Example

RenderingAPIRequest renderingRequest = new RenderingAPIRequest();
renderingRequest.parameters.put('renderType', 'contentName');
renderingRequest.listParameters.put('contentNames', new List<String>{'Content 1'});
 
List<String> contentLayouts = new List<String>{'ArticleDetail', 'ArticleSummary'};
renderingRequest.listParameters.put('contentLayouts', contentLayouts);
 
Map<String, String> parameters = new Map<String, String>();
parameters.put('renderingRequest', json.serialize(renderingRequest));
parameters.put('action', 'getRenderedContent');
parameters.put('service', 'OrchestraRenderingAPI');
parameters.put('sname', 'site_name'); // Replace site_name with the name of your OrchestraCMS site 
parameters.put('application', 'runtime');
parameters.put('apiVersion', '5.0');
 
String response = cms.ServiceEndpoint.doActionApex(parameters);
JSONMessage.APIResponse apiResponse = (JSONMessage.APIResponse) json.deserialize(response, JSONMessage.APIResponse.class);
 
if (!apiResponse.isSuccess)
    throw new APIException('Could not retrieve renderings for this node');
if (apiResponse.type != 'RenderResultBundle')
    throw new APIException('Unexpected result from Rendering API');
 
System.Debug(apiResponse.responseObject);

JavaScript Request Example

var listparams = {
    contentNames: ['Content 1'],
    contentLayouts: ['Article Detail', 'Article Summary']
};
var params = {
    renderType: 'contentName'
};
var renderingRequest = {
    listParameters: listparams,
    parameters: params,
    requestFlags: {}
};
var response; // Used to get the JSON Object Response from action
var data = {
    service: 'OrchestraRenderingAPI',
    action: 'getRenderedContent',
    renderingRequest: JSON.stringify(renderingRequest),
    apiVersion: '5.0'
};
// Handle response of a successful ajax call
var callBackHandler = function(json, Success) {
    console.log(json);
    response = JSON.parse(json);
}
var options = {
    cb: callBackHandler,
    cbHandlerOnComplete: function(textStatus) {}, // Handle response on complete
    readonly: true // Whether it is a read only call
};
doServiceRequest(data, options);

JSON-Serialized Response Example

{
    error: null
    isSuccess: true
    message: ""
    responseObject: {
        "renderings": [
            {
                "tagPaths": null,
                "socialBundle": null,
                "renderMap": {
                    "ArticleDetail":"<div><span>I am rendered content</span></div>",
                    "ArticleSummary": "<div><span>I am rendered content</span></div>"
                },
                "originId": "a00000000000000000",
                "message": null,
                "contentId": "a00000000000000000",
                "contentBundle": null
            }
        ],
        "pageRenderings": null,
        "message": "Success",
        "contentRemaining": false
    }
    timeNow: "2017-06-26T00:00:00.000Z"
    transactionId: null
    type: "RenderResultBundle"
}
 
The returned API Response is a generic object that contains a responseObject for the specific data from the request.

getRenderedContent (by Content Origin ID)

This method provides rendered content based on the provided parameters. There are four available options for content retrieval. Possible values are "contentName", "contentType", "originId", and "taxonomy". The following table outlines the required and optional parameters for each of the four methods.

To getRenderedContent by Content Origin ID use a string value of 'originId' for the renderType parameter.

Parameters

  • renderType: String, Method of content retrieval. Must be set to 'originId' to getRenderedContent by Content Origin ID.
  • targeted : Boolean (optional), Apply targeting to the content.
  • order : String (optional; default: 'level_priority_date'), The code that determines the order of the content. Accepted String values are:
    • publish_date - retrieves results in descending order by published start date.
    • alpha - retrieves results in ascending order by content name.
    • date - retrieves results in descending order by original published start date.
    • priority_date - retrieves results in descending order by priority, then original published start date.
    • level_priority_date - orders results by access level value, then priority, then original published start date.
  • limit : Integer (optional), Limit the results by this value.
  • offset : Integer (optional), Get results from this number forward to limit.  For example if the offset is 0 and the limit is 20 the first 20 items are returned.  If the offset is 20 and the limit is 20 the second 20 items are returned.
  • status : String (optional; default: 'all'), Used to specify whether published, unpublished, or both will be returned. This value is ignored in production mode. Accepted String values are:
    • all - retrieves both published and unpublished content.
    • published - retrieves only published content.
    • unpublished - retrieves only unpublished content.

List Parameters

  • originIds : List<ID>, A list of content origin IDs.
  • contentTypesList<String> (optional), A list of content type names.
  • contentLayouts : List<String> (optional), A list of layout names for content rendering. All associated content layouts are returned by default.
  • predefinedTargetsList<List<String>> (optional), A list of lists of predefined target names. Applies the specified predefined targets on the content. Content will be retrieved if at least one predefined target in each inner list applies to it. For example, each item in an inner list is combined using an OR operator while each inner list is combined together using an AND operator. Not applicable if targeted flag is set to true.
  • adHocTargetsMap<String,List<String>> (optional),  Ad Hoc target map. The Key is the target name and the Value is the list of Ad Hoc values. Content will be retrieved if it has the Ad Hoc target applied to it and has at least one of the Ad Hoc values in the list. Not applicable if targeted parameter is set to true.

Apex Request Example

RenderingAPIRequest renderingRequest = new RenderingAPIRequest();
renderingRequest.parameters.put('renderType', 'originId');
renderingRequest.listParameters.put('originIds', new List<Id>{'a00000000000000000', 'a00000000000000001'});
 
List<String> contentLayouts = new List<String>{'ArticleDetail'};
renderingRequest.listParameters.put('contentLayouts', contentLayouts);
 
Map<String, String> parameters = new Map<String, String>();
parameters.put('renderingRequest', json.serialize(renderingRequest));
parameters.put('action', 'getRenderedContent');
parameters.put('service', 'OrchestraRenderingAPI');
parameters.put('sname', 'site_name'); // Replace site_name with the name of your OrchestraCMS site 
parameters.put('application', 'runtime');
parameters.put('apiVersion', '5.0');
 
String response = cms.ServiceEndpoint.doActionApex(parameters);
JSONMessage.APIResponse apiResponse = (JSONMessage.APIResponse) json.deserialize(response, JSONMessage.APIResponse.class);
 
if (!apiResponse.isSuccess)
    throw new APIException('Could not retrieve renderings for this node');
if (apiResponse.type != 'RenderResultBundle')
    throw new APIException('Unexpected result from Rendering API');
 
System.Debug(apiResponse.responseObject);

JavaScript Request Example

var listparams = {
    originIds: ['a00000000000000000'],
    contentLayouts: ['Article Detail']
};
var params = {
    renderType: 'originId'
};
var renderingRequest = {
    listParameters: listparams,
    parameters: params,
    requestFlags: {}
};
var response; // Used to get the JSON Object Response from action
var data = {
    service: 'OrchestraRenderingAPI',
    action: 'getRenderedContent',
    renderingRequest: JSON.stringify(renderingRequest),
    apiVersion: '5.0'
};
// Handle response of a successful ajax call
var callBackHandler = function(json, Success) {
    console.log(json);
    response = JSON.parse(json);
}
var options = {
    cb: callBackHandler,
    cbHandlerOnComplete: function(textStatus) {}, // Handle response on complete
    readonly: true // Whether it is a read only call
};
doServiceRequest(data, options);

JSON-Serialized Response Example

{
    error: null
    isSuccess: true
    message: ""
    responseObject: {
        "renderings": [
            {
                "tagPaths": null,
                "socialBundle": null,
                "renderMap": {
                    "ArticleDetail":"<div><span>I am rendered content</span></div>"
                },
                "originId": "a00000000000000000",
                "message": null,
                "contentId": "a00000000000000000",
                "contentBundle": null
            }
        ],
        "pageRenderings": null,
        "message": "Success",
        "contentRemaining": false
    }
    timeNow: "2017-06-26T00:00:00.000Z"
    transactionId: null
    type: "RenderResultBundle"
}
 
The returned API Response is a generic object that contains a responseObject for the specific data from the request.

getRenderedContent (by Content Type)

This method provides rendered content based on the provided parameters. There are four available options for content retrieval. Possible values are "contentName", "contentType", "originId", and "taxonomy". The following table outlines the required and optional parameters for each of the four methods.

To getRenderedContent by Content Type use a string value of 'contentType' for the renderType parameter.

Parameters

  • renderType: String, Method of content retrieval. Must be set to 'contentType' to getRenderedContent by Content Type.
  • targeted : Boolean (optional), Apply targeting to the content.
  • order : String (optional; default: 'level_priority_date'), The code that determines the order of the content. Accepted String values are:
    • publish_date - retrieves results in descending order by published start date.
    • alpha - retrieves results in ascending order by content name.
    • date - retrieves results in descending order by original published start date.
    • priority_date - retrieves results in descending order by priority, then original published start date.
    • level_priority_date - orders results by access level value, then priority, then original published start date.
  • limit : Integer (optional), Limit the results by this value.
  • offset : Integer (optional), Get results from this number forward to limit.  For example if the offset is 0 and the limit is 20 the first 20 items are returned.  If the offset is 20 and the limit is 20 the second 20 items are returned.
  • status : String (optional; default: 'all'), Used to specify whether published, unpublished, or both will be returned. This value is ignored in production mode. Accepted String values are:
    • all - retrieves both published and unpublished content.
    • published - retrieves only published content.
    • unpublished - retrieves only unpublished content.

List Parameters

  • contentTypesList<String>, A list of content type names.
  • contentNamesList<String>, The content names to search for. Can be the name of the content in any of its translated languages.
  • contentLayouts : List<String> (optional), A list of layout names for content rendering. All associated content layouts are returned by default.
  • predefinedTargetsList<List<String>> (optional), A list of lists of predefined target names. Applies the specified predefined targets on the content. Content will be retrieved if at least one predefined target in each inner list applies to it. For example, each item in an inner list is combined using an OR operator while each inner list is combined together using an AND operator. Not applicable if targeted flag is set to true.
  • adHocTargetsMap<String,List<String>> (optional),  Ad Hoc target map. The Key is the target name and the Value is the list of Ad Hoc values. Content will be retrieved if it has the Ad Hoc target applied to it and has at least one of the Ad Hoc values in the list. Not applicable if targeted parameter is set to true.

Apex Request Example

RenderingAPIRequest renderingRequest = new RenderingAPIRequest();
renderingRequest.parameters.put('renderType', 'contentType');
renderingRequest.listParameters.put('contentTypes', new List<String>{'Article'});
 
Map<String, String> parameters = new Map<String, String>();
parameters.put('renderingRequest', json.serialize(renderingRequest));
parameters.put('action', 'getRenderedContent');
parameters.put('service', 'OrchestraRenderingAPI');
parameters.put('sname', 'site_name'); // Replace site_name with the name of your OrchestraCMS site 
parameters.put('application', 'runtime');
parameters.put('apiVersion', '5.0');
 
String response = cms.ServiceEndpoint.doActionApex(parameters);
JSONMessage.APIResponse apiResponse = (JSONMessage.APIResponse) json.deserialize(response, JSONMessage.APIResponse.class);
 
if (!apiResponse.isSuccess)
    throw new APIException('Could not retrieve renderings for this node');
if (apiResponse.type != 'RenderResultBundle')
    throw new APIException('Unexpected result from Rendering API');
 
System.Debug(apiResponse.responseObject);

JavaScript Request Example

var listparams = {
    contentTypes: ['Article']
};
var params = {
    renderType: 'contentType'
};
var renderingRequest = {
    listParameters: listparams,
    parameters: params,
    requestFlags: {}
};
var response; // Used to get the JSON Object Response from action
var data = {
    service: 'OrchestraRenderingAPI',
    action: 'getRenderedContent',
    renderingRequest: JSON.stringify(renderingRequest),
    apiVersion: '5.0'
};
// Handle response of a successful ajax call
var callBackHandler = function(json, Success) {
    console.log(json);
    response = JSON.parse(json);
}
var options = {
    cb: callBackHandler,
    cbHandlerOnComplete: function(textStatus) {}, // Handle response on complete
    readonly: true // Whether it is a read only call
};
doServiceRequest(data, options);

JSON-Serialized Response Example

{
    error: null
    isSuccess: true
    message: ""
    responseObject: {
        "renderings": [
            {
                "tagPaths": null,
                "socialBundle": null,
                "renderMap": {
                    "ArticleDetail":"<div><span>I am rendered content</span></div>",
                    "ArticleDetailWithRelated": "<div><span>I am rendered content</span></div>",
                    "ArticleSummary": "<div><span>I am rendered content</span></div>",
                    "ArticleSummarySmallWithImage": "<div><span>I am rendered content</span></div>"
                },
                "originId": "a00000000000000000",
                "message": null,
                "contentId": "a00000000000000000",
                "contentBundle": null
            }
        ],
        "pageRenderings": null,
        "message": "Success",
        "contentRemaining": false
    }
    timeNow: "2017-06-26T00:00:00.000Z"
    transactionId: null
    type: "RenderResultBundle"
}
 
The returned API Response is a generic object that contains a responseObject for the specific data from the request.

getRenderedContent (by Taxonomy Tag Path)

This method provides rendered content based on the provided parameters. There are four available options for content retrieval. Possible values are "contentName", "contentType", "originId", and "taxonomy". The following table outlines the required and optional parameters for each of the four methods.

To getRenderedContent by Taxonomy Tag Path, use a string value of 'taxonomy' for the renderType parameter.

Parameters

  • renderType: String, Method of content retrieval. Must be set to 'taxonomy' to getRenderedContent by Taxonomy Tag Path.
  • targeted : Boolean (optional), Apply targeting to the content.
  • order : String (optional; default: 'level_priority_date'), The code that determines the order of the content. Accepted String values are:
    • publish_date - retrieves results in descending order by published start date.
    • alpha - retrieves results in ascending order by content name.
    • date - retrieves results in descending order by original published start date.
    • priority_date - retrieves results in descending order by priority, then original published start date.
    • level_priority_date - orders results by access level value, then priority, then original published start date.
  • limit : Integer (optional), Limit the results by this value.
  • offset : Integer (optional), Get results from this number forward to limit.  For example if the offset is 0 and the limit is 20, the first 20 items are returned.  If the offset is 20 and the limit is 20, the second 20 items are returned.
  • status : String (optional; default: 'all'), Used to specify whether published, unpublished, or both will be returned. This value is ignored in production mode. Accepted String values are:
    • all - retrieves both published and unpublished content.
    • published - retrieves only published content.
    • unpublished - retrieves only unpublished content.

List Parameters

  • contentTypesList<String>, A list of content type names.
  • tagPaths : List<String>, A list of taxonomy tag paths.
  • layoutsForTaxonomy : List<List<String>>, For more information on this parameter, see the layoutsForTaxonomy parameter section.
  • predefinedTargetsList<List<String>> (optional), A list of lists of predefined target names. Applies the specified predefined targets on the content. Content will be retrieved if at least one predefined target in each inner list applies to it. For example, each item in an inner list is combined using an OR operator while each inner list is combined together using an AND operator. Not applicable if targeted flag is set to true.
  • adHocTargetsMap<String,List<String>> (optional),  Ad Hoc target map. The Key is the target name and the Value is the list of Ad Hoc values. Content will be retrieved if it has the Ad Hoc target applied to it and has at least one of the Ad Hoc values in the list. Not applicable if targeted parameter is set to true.

Apex Request Example

List<String> tagPaths = new List<String>();
tagPaths.add('/root_taxonomy/level1/level2');
 
RenderingAPIRequest renderingRequest = new RenderingAPIRequest();
renderingRequest.parameters.put('renderType', 'taxonomy');
renderingRequest.listParameters.put('contentTypes', new List<String>{'Article'});
renderingRequest.listParameters.put('tagPaths', tagPaths);
 
List<String> layoutsForTaxonomy = new List<String>{'ArticleDetail'};
renderingRequest.layoutsForTaxonomy = new List<List<String>>{layoutsForTaxonomy};
 
Map<String, String> parameters = new Map<String, String>();
parameters.put('renderingRequest', json.serialize(renderingRequest));
parameters.put('action', 'getRenderedContent');
parameters.put('service', 'OrchestraRenderingAPI');
parameters.put('sname', 'site_name'); // Replace site_name with the name of your OrchestraCMS site 
parameters.put('application', 'runtime');
parameters.put('apiVersion', '5.0');
 
String response = cms.ServiceEndpoint.doActionApex(parameters);
JSONMessage.APIResponse apiResponse = (JSONMessage.APIResponse) json.deserialize(response, JSONMessage.APIResponse.class);
 
if (!apiResponse.isSuccess)
    throw new APIException('Could not retrieve renderings for this node');
if (apiResponse.type != 'RenderResultBundle')
    throw new APIException('Unexpected result from Rendering API');
 
System.Debug(apiResponse.responseObject);

JavaScript Request Example

var listparams = {
    tagPaths: ['/root_taxonomy/level1/level2'],
    contentTypes: ['Article']
};
var params = {
    renderType: 'taxonomy'
};
var renderingRequest = {
    listParameters: listparams,
    parameters: params,
    layoutsForTaxonomy: [['ArticleDetail']],
    requestFlags: {}
};
var response; // Used to get the JSON Object Response from action
var data = {
    service: 'OrchestraRenderingAPI',
    action: 'getRenderedContent',
    renderingRequest: JSON.stringify(renderingRequest),
    apiVersion: '5.0'
};
// Handle response of a successful ajax call
var callBackHandler = function(json, Success) {
    console.log(json);
    response = JSON.parse(json);
}
var options = {
    cb: callBackHandler,
    cbHandlerOnComplete: function(textStatus) {}, // Handle response on complete
    readonly: true // Whether it is a read only call
};
doServiceRequest(data, options);

JSON-Serialized Response Example

error: null
isSuccess: true
message: ""
responseObject:
    {
        "renderings": [
            {
                "tagPaths": ["/root_taxonomy/level1/level2"],
                "socialBundle": null,
                "renderMap": {
                    "ArticleDetail": ""
                },
                "originId": "a00000000000000000",
                "message": null,
                "contentId": "a00000000000000000",
                "contentBundle": null
            }
        ],
        "pageRenderings": null,
        "message": "Success",
        "contentRemaining": false
    }
timeNow: "2017-06-26T00:00:00.000Z"
transactionId: null
type: "RenderResultBundle"
 
The returned API Response is a generic object that contains a responseObject for the specific data from the request.
 

If offset is larger than the total amount of returned content or if limit is set to zero, the following message will be displayed.

"Success - Content was found but nothing was rendered. Double check the layout names and ensure the limit is greater than 0."

getRenderedPage

This method provides a rendered page based on the passed parameters. The only supported parameter for this method is pageName. When called outside of an OrchestraCMS context, this call supports the page_mode and ocmsLang context parameters during intialization.

Parameters

  • pageName : String, The name of the page to retrieve the rendering for.

Apex Request Example

RenderingAPIRequest renderingRequest = new RenderingAPIRequest();
renderingRequest.parameters.put('pageName', 'Home Page');
Map<String, String> parameters = new Map<String, String>();
parameters.put('renderingRequest', json.serialize(renderingRequest));
parameters.put('action', 'getRenderedPage');
parameters.put('service', 'OrchestraRenderingAPI');
parameters.put('sname', 'site_name'); // Replace site_name with the name of your OrchestraCMS site
parameters.put('application', 'runtime');
parameters.put('apiVersion', '5.0');
parameters.put('runtime', 'Salesforce');
parameters.put('page_mode', 'production');
parameters.put('ocmsLang', UserInfo.getLocale());

String response = cms.ServiceEndpoint.doActionApex(parameters);
JSONMessage.APIResponse apiResponse = (JSONMessage.APIResponse) json.deserialize(response, JSONMessage.APIResponse.class);
 
if (!apiResponse.isSuccess)
    throw new APIException('Could not retrieve page rendering');
if (apiResponse.type != 'RenderResultBundle')
    throw new APIException('Unexpected result from Rendering API');

System.Debug(apiResponse.responseObject);

JavaScript Request Example

var params = {
    pageName: 'Home Page'
};
var renderingRequest = {
    parameters: params,
    requestFlags: {}
};
var response; // Used to get the JSON Object Response from action
var data = {
    service: 'OrchestraRenderingAPI',
    action: 'getRenderedPage',
    renderingRequest: JSON.stringify(renderingRequest),
    apiVersion: '5.0'
};
// Handle response of a successful ajax call
var callBackHandler = function(json, Success) {
    console.log(json);
    response = JSON.parse(json);
}
var options = {
    cb: callBackHandler,
    cbHandlerOnComplete: function(textStatus) {}, // Handle response on complete
    readonly: true
};
doServiceRequest(data, options);

JSON-Serialized Response Example

error: null
isSuccess: true
message: ""
responseObject: {
    "renderings": [],
    "pageRenderings": [
        {
            "url":"/HomePage",
            "rendering":"<html><head><title>Home Page</title></head><body>This is my page</body></html>",
            "name":"Home Page"
        }
    ],
    "message": "Success",
    "contentRemaining": false
}
timeNow: "2017-06-26T00:00:00.000Z"
transactionId: null
type: "RenderResultBundle"
 
The returned API Response is a generic object that contains a responseObject for the specific data from the request.
 

It is a good practice to create a dedicated content type for content layouts that call the Rendering API during markup generation.

RenderingAPIRequest

The RenderingAPIRequest class is accepted by all Rendering API methods. All method parameters are passed to the API within this class. This simplifies the process of writing API clients, as there is only one structure the developer needs to learn and common parameters are shared across methods.

List Parameters

  • adHocTargets : Map<String, List<String>>,  Ad Hoc target map. The Key is the target name and the Value is the list of Ad Hoc values. Content will be retrieved if it has the Ad Hoc target applied to it and has at least one of the Ad Hoc values in the list. Not applicable if targeted parameter is set to true.
  • predefinedTargets : List<List<String>>, A list of lists of predefined target names. Applies the specified predefined targets on the content. Content will be retrieved if at least one predefined target in each inner list applies to it. For example, each item in an inner list is combined using an OR operator while each inner list is combined together using an AND operator. Not applicable if targeted flag is set to true.
  • layoutsForTaxonomy : List<List<String>>, A list of lists of layout names. Each list of layout names corresponds to a level of the taxonomy, starting from the last node in the tag path.
  • pageInstanceProperties : Map<String, String>, For page rendering, these are page parameters to append to the URL of the rendered page. For contentRendering, these act as attributes that are forwarded to the content item for use in rendering (for example, the Content View content layout refers to the content ID included in the page parameters).
  • contentProperties : Map<String, String>, Custom properties specific to the content.
  • contentLayoutPropertiesMap<String, String>, Custom properties specific to the content layout.

Flags

Additional flags can be supplied to the RenderingAPIRequest depending on the end requirements. All flags expect a Boolean value.

  • targeted : (default: false), Apply targeting to the content.
  • noRendering : (default: false), Do not return content renderings. Return a simplified content bundle instead. The returned renderMap will be null.
  • withContentBundle : (default: false), Return a simplified content bundle in addition to the renderings.
  • withSocialBundle : (default: false), Return a social bundle in addition to the renderings.
  • orBetweenTargetFilters : (default: false), If true, performs an OR operation between the collection of predefinedTargets and the collection of adHocTargets. If false, performs an AND operation between the collection of predefinedTargets and the collection of adHocTargets. Only applicable if you have both predefinedTargets and adHocTargets parameters specified.

Apex Example - Setting Flags for a RenderingAPI Request

RenderingAPIRequest renderingRequest = new RenderingAPIRequest();
renderingRequest.requestFlags.put('targeted', true);
renderingRequest.requestFlags.put('noRendering', true);
renderingRequest.requestFlags.put('withContentBundle', true);
renderingRequest.requestFlags.put('withSocialBundle', true);
 

All Rendering API requests return a RenderResultBundle. Please see the RenderResultBundle page for additional information.

layoutsForTaxonomy parameter

The layoutsForTaxonomy parameter is used when rendering content items by tag path. When specifying this parameter, you are telling the Rendering API which layouts you want returned at each level of the taxonomy, starting from the level indicated by the tagPaths parameter. If you do not pass a list of layouts for a given level, content at that level will not be returned. For this reason, the number of lists passed in to layoutsForTaxonomy is an implicit specifiication of the depth of the taxonomy structure to be searched.

Consider the diagram below. This is a visual depiction of a seven-level taxonomy structure, along with the items tagged at each level. For each item, the content name, content type, and content layout are displayed. Content items can have more than one layout, but for this example we are assuming each has only one.

As an example, this diagram tells us that content item GHI has a content type of Text, a content layout of TextBlock, and is tagged at the path root/level1/level2/level3.

Based on this diagram, the following table illustrates which content items will be returned based on the provided inputs for tagPaths and layoutsForTaxonomy. Assume that for the contentTypes parameter, both Media and Text are specified.

tagPaths layoutsForTaxonomy Content returned
root/level1/level2 {'Image'}
{'TextBlock', 'Image'}
{'TextBlock'}
{'TextBlock'}
DEF, GHI, JKL
root/level1/level2/level3 {'TextBlock'}
{}
{'TextBlock'}
{'TextBlock'}
GHI, STU
root/level1/level2/level3/level4 {'TextBlock', 'Image'} JKL, MNO
root/level1 {'SmallBlock', 'Image'}
{'TextBlock'}
{'Image'}
(none)

 

 
 

To use the Rendering API off platform, the following flags must be set. This is assuming the running user has an OrchestraCMS profile.

contextParams.put('sitename', 'site_name');
contextParams.put('runtime', 'Salesforce');
contextParams.put('page_mode', 'prev');

Page mode can be 'prev', 'secureprev', or 'production'