Sites Component API for Oracle Content Management

Namespace: SCSComponentAPI (Common)

QuickNav

SCSComponentAPI

SCSComponentAPI

Methods

checkRenderState(state) → {boolean}

Checks whether the current rendering state matches the requested value. The "state" is a modifier of the "mode" value.
For example, the render "mode" may be SCSComponentAPI.RENDER_MODE.RUNTIME but the "state" may be that the site is in preview or viewing a published page.
In most cases, you will not need to be concerned about the state value. However, you may wish the component to render differently if, for example, it is rendering as a small thumbnail.
Parameters:
Name Type Description
state SCSComponentAPI.RENDER_STATE value to check for
Returns:
true if the requested render state is applicable
Type
boolean
Gets the link data for a given page.
Parameters:
Name Type Attributes Description
pageId String The target page ID.
options Object <optional>
The options object.
Properties
Name Type Attributes Description
context String <optional>
The page context. This is only available in the design environment.
contentType String The target content type.
contentId String <optional>
The target content ID.
contentName String <optional>
The target content name.
Returns:
The link data, including href, target, and hideInNavigation properties.
Type
Object

getCacheKey(keyName) → {String}

Gets the cache key for the given section.

Parameters:
Name Type Description
keyName SCSComponentAPI.CACHE_KEY
Returns:
The cache key for the given section.
Type
String

getComponentInstanceData(componentId) → {Object|undefined}

Gets the component's stored data.
Parameters:
Name Type Description
componentId String The component ID.
Returns:
Returns the component's stored data object or undefined.
Type
Object | undefined

getContentClient() → {Object}

Returns a ContentClient instance, which can be used to obtain information from content REST calls.
Returns:
A ContentClient object.
Type
Object

getCustomPageProperty(propertyName, pageIdopt) → {String|undefined}

Gets a page property value given a page ID and property name.
Parameters:
Name Type Attributes Description
propertyName String Property name.
pageId String <optional>
The page ID.
Returns:
The property value.
Type
String | undefined

getCustomSiteProperty(propertyName) → {String|undefined}

Gets a custom site property value given a property name.
Parameters:
Name Type Description
propertyName String Property name.
Returns:
The property value.
Type
String | undefined

getDefaultPageProperty(propertyName) → {String|undefined}

Gets a default page property value given a property name.
Parameters:
Name Type Description
propertyName String Property name.
Returns:
The property value.
Type
String | undefined

getDeviceInfo() → {Object}

Gets info about current device.

Customizations to the controller code will not take effect in design time, only runtime.
Returns:
An object with device info.

Default return object: { isMobile: [true | false], isIOS: [true | false] }
Type
Object

getMarked() → {Object}

Gets the page's marked object, used for Markdown parsing.
Returns:
The marked object reference.
Type
Object

getMustache() → {Object}

Gets the page's Mustache object.
Returns:
The Mustache object reference.
Type
Object

getMustacheTags() → {SCSComponentAPI.mustacheTags}

Returns the combined list of useful Mustache tags including those defined with the SCSMacro object.
Returns:
a object containing a top-level "scs" object that can be used to access all OCM Mustache tags.
Type
SCSComponentAPI.mustacheTags

getPageInfo() → {SCSComponentAPI.PageInfo}

Gets the detailed information about the page.
Returns:
all the details about the page.
Type
SCSComponentAPI.PageInfo

getRenderMode() → {SCSComponentAPI.RENDER_MODE}

Gets the current rendering mode.
Returns:
The current rendering mode.
Type
SCSComponentAPI.RENDER_MODE
Example
SCSComponentAPI.getRenderMode();
// => 'edit'
// Possible return values: SCSComponentAPI.RENDER_MODE.EDIT | SCSComponentAPI.RENDER_MODE.NAVIGATE | SCSComponentAPI.RENDER_MODE.RUNTIME | SCSComponentAPI.RENDER_MODE.COMPILE

getSiteInfo() → {SCSComponentAPI.SiteInfo}

Gets the detailed information about the site.
Returns:
all the details about the site.
Type
SCSComponentAPI.SiteInfo

getSiteProperty(propertyName) → {String|undefined}

Gets a site property value given a property name.
Parameters:
Name Type Description
propertyName String Property name.
Returns:
The property value.
Type
String | undefined

getURLPrefix(prefixName) → {String}

Gets the prefix to the requested resource.

Parameters:
Name Type Description
prefixName SCSComponentAPI.URL_PREFIX
Returns:
The URL prefix for the given key.
Type
String

loadResource(args) → {Promise}

Loads the requested resource into the page.
If the resource is of type "text", the resource is loaded and returned.
If the resource is of type "css", when rendering in the browser, it inserts the CSS into the HEAD of the page. While, during compile, the resource is returned.
Parameters:
Name Type Description
args Object parameters to load the resource.
Properties
Name Type Description
resource String name of the resource to load.
path String the path to the resource.
type 'text' | 'css' the type of resource to load.
Returns:
the loaded resource or undefined if resource is automatically added to the page.
Type
Promise

Type Definitions

CACHE_KEY

Type:
  • Object
Properties:
Name Type Description
PRODUCT string 'product' product release version
SITE string 'site' site resources, changed whenever site is republished
THEME string 'theme' theme resources, changed whenever the theme is republished
COMPONENT string 'component' component resources, changed whenever any component is republished
CONTENT string 'content' content resources, changed whenever any item is republished to the site's publishing channel

RENDER_MODE

Type:
  • Object
Properties:
Name Type Description
EDIT string 'edit' page is rendering in the site builder in edit mode.
NAVIGATE string 'navigate' page is rendering in the site builder in navigate (view) mode'.
RUNTIME string 'runtime' page is rendering in a published site or in preview.
COMPILE string 'compile' page is being compiled.

RENDER_STATE

Type:
  • Object
Properties:
Name Type Description
ANNOTATION string 'annotation' user is annotating the site page. Available in both "NAVIGATE" and "EDIT" modes
PREVIEW string 'preview' user is previewing the site page. Available in "RUNTIME" mode
THUMBNAIL string 'thumbnail' user is viewing a content layout in the settings panel. The thumbnail is rendered in an iFrame.

URL_PREFIX

Type:
  • Object
Properties:
Name Type Description
CDN string 'cdn' the sitesCloudCDN value, if present.
CONTENT string 'content' the content URL prefix with siteId, variantId and filename.
COMPONENT_CATALOG string 'componentCatalog' the URL prefix to the component folder.
DIST_DIR string 'distDir' the distribution directory prefix.
SITE_PATH string 'sitePath' the site path prefix including a cache key.
THEME_DESIGN string 'themeDesign' the theme's design URL prefix.
THEME string 'theme' the theme URL prefix.

mustacheTags

Defines the set of Mustache tags beneath an "scs" object. This also includes all the SCSMacros values.
Type:
  • Object
Properties:
Name Type Description
getRenditionURL lambda {{#scs.getRenditionURL}}{{id}}{{/scs.getRenditionURL}}, takes "id,format,type,download" comma separated values.
expandMacros lambda {{#scs.expandMacros}}{{{aRichTextField}}}{{/scs.expandMacros}}, expands any recognized macros withing "aRichTextField" value.
processMarked lambda {{#scs.processMarked}}{{{aMarkDownField}}}{{/scs.processMarked}}, processes the markdown text into HTML.
expandMarked lambda {{#scs.expandMarked}}{{{aMarkDownField}}}{{/scs.expandMarked}}, combines expandMacros with processMarked.
formatDate object {{#scs.formatDate.toDateString}}{{dateValue}}{{/scs.formatDate.toDateString}}, allow for basic built-in date formatting functions
Properties
Name Type Description
toDateString lambda e.g. 'Thu Mar 23 2023'
toISOString lambda e.g. '2023-03-23T16:57:25.488Z'
toLocaleDateString lambda e.g. '3/23/2023'
toLocaleString lambda e.g. '3/23/2023, 9:57:52 AM'
toLocaleTimeString lambda e.g. '9:58:06 AM'