Ceros SDK: Experience-Level Commands

Before you begin…

Ceros Developer Tools are intended for experienced web developers. Using these features requires advanced knowledge of JavaScript and an understanding of common SDK coding techniques.

If you’re just looking to add Ceros content to your website, please see our embedding article.

Experience-level commands

Accessors and utility functions

getTitle()

called on: CerosExperience
arguments: none

Returns a string that contains the title of the Ceros experience.

var experienceTitle = myExperience.getTitle();

findPageById( pageId )

called on: CerosExperience
arguments:
pageId – the SDK ID of the page to retrieve

Returns a CerosPage representing either the single page that has ID pageId, or null if the ID can not be found.

var myPage = myExperience.findPageById('a-page-id');
if (myPage){
    myPage.disable(); //disables the page, if it was found
}

findPagesByTag( tag )

called on: CerosExperience
arguments:
tag – a string

Returns a CerosPageCollection containing all pages in the experience that have been tagged with tag in the Studio.

var taggedPages = myExperience.findPagesByTag("foo");

getCurrentPage()

called on: CerosExperience
arguments: none

Returns a CerosPage representing only the current page of the experience.

var page = myExperience.getCurrentPage();

findLayerById( layerId )

called on: CerosExperience
arguments:
layerId – the SDK ID of the layer to retrieve

Returns a CerosLayer representing either the single layer that has ID layerId, or null if the ID can not be found.

var myLayer = myExperience.findLayerById('a-layer-id');
if (myLayer){
    myLayer.hide(); //hides the layer, if it was found
}

This will also fetch layers within smartgroups by their SDK ID.
Commands run on layers within smartgroups apply to all uses of the smartgroup.


findLayersByTag( tag )

called on: CerosExperience
arguments:
tag – a string

Returns a CerosLayerCollection containing all layers in the experience that have been tagged with tag in the Studio.

var taggedLayers = myExperience.findLayersByTag("foo");

This includes layers within smartgroups. Commands run on layers within smartgroups apply to all uses of the smartgroup.


findAllLayers()

called on: CerosExperience
arguments: none

Returns a CerosLayerCollection. All layers in the experience are returned.

var layers = myExperience.findAllLayers();
layers.show(); //shows all layers in the experience

This includes layers within smartgroups. Commands run on layers within smartgroups apply to all uses of the smartgroup.


findSmartgroupById( smartgroupId )

called on: CerosExperience
arguments:
smartgroupId – the SDK ID of the smartgroup to retrieve

Returns a CerosSmartgroup representing either the single smartgroup that has ID smartgroupId, or null if the ID can not be found.

var mySmartgroup = myExperience.findSmartgroupById('a-smartgroup-id');
if (mySmartgroup){
    mySmartgroup.hide(); //hides the smartgroup, if it was found
}

findSmartgroupsByTag( tag )

called on: CerosExperience
arguments:
tag – a string

Returns a CerosSmartgroupCollection containing all smartgroups in the experience that have been tagged with tag in the Studio.

var taggedSmartgroups = myExperience.findSmartgroupsByTag("foo");

findAllSmartgroups()

called on: CerosExperience
arguments: none

Returns a CerosSmartgroupCollection. All smartgroups in the experience are returned.

var smartgroups = myExperience.findAllSmartgroups();
smartgroups.show(); //shows all smartgroups in the experience

findSmartgroupsWithAnyTags( tags )

called on: CerosExperience
arguments:
tags – an array of strings

Returns a CerosSmartgroupCollection containing all smartgroups tagged with any of the tags passed in the tags array in the studio.

var taggedSmartgroups = myExperience.findSmartgroupsWithAnyTags(["foo","bar"]);

findSmartgroupsWithAllTags( tags )

called on: CerosExperience
arguments:
tags – an array of strings

Returns a CerosSmartgroupCollection containing all smartgroups tagged with all of the tags passed in the tags array in the studio.

var taggedSmartgroups = myExperience.findSmartgroupsWithAllTags(["foo","bar"]);

findComponentById( component-id )

called on: CerosExperience
arguments:
component-id – the SDK ID of the component to retrieve

Returns a CerosComponent that represents the component with ID component-id. If there is no component with this ID, the command will return null.

var component = myExperience.findComponentById('a-component-id');

This will also fetch components within smartgroups by their SDK ID.
Commands run on components within smartgroups apply to all uses of the smartgroup.


findComponentsByTag( tag )

called on: CerosExperience
arguments:
tag – a string

Returns a CerosComponentCollection containing all components in the experience that have been tagged with tag in the Studio.

var taggedComponents = myExperience.findComponentsByTag("foo");

This includes components within smartgroups. Commands run on components within smartgroups apply to all uses of the smartgroup.


findComponentsWithAnyTags( tags )

called on: CerosExperience
arguments:
tags – an array of strings

Returns a CerosComponentCollection containing all components tagged with any of the tags passed in the tags array in the studio.

var taggedComponents = myExperience.findComponentsWithAnyTags(["foo","bar"]);

This includes components within smartgroups. Commands run on components within smartgroups apply to all uses of the smartgroup.


findComponentsWithAllTags( tags )

called on: CerosExperience
arguments:
tags – an array of strings

Returns a CerosComponentCollection containing all components tagged with all of the tags passed in the tags array in the studio.

var taggedComponents = myExperience.findComponentsWithAllTags(["foo","bar"]);

This includes components within smartgroups. Commands run on components within smartgroups apply to all uses of the smartgroup.


getCurrentUserId()

called on: CerosExperience arguments: none

Returns the ID of the current user viewing the experience as a string.

var userId = myExperience.getCurrentUserId();

Page navigation commands

goToNextPage()

called on: CerosExperience
arguments: none

Navigates the experience to the page directly after the one the user is currently on. If the user is on the last page (if the experience is not a carousel), or if the experience only has one page, the command will do nothing.

myExperience.goToNextPage();

goToPreviousPage()

called on: CerosExperience
arguments: none

Navigates the experience to the page directly before the one the user is currently on. If the user is on the first page (if the experience is not a carousel), or if the experience only has one page, the command will do nothing.

myExperience.goToPreviousPage();

goToPage( pageNum )

called on: CerosExperience
arguments:
pageNum – The number of the page to go to. Must be between 1 and the total number of pages in the experience, inclusive.

Navigates the experience to the page specified by pageNum. If pageNum is not a valid page in the experience, the command will do nothing.

myExperience.goToPage(3);

Embedded Player SDK

  1. SDK Overview
  2. Basic concepts
  3. Commands
    1. Experience-level Commands
    2. Page-level Commands
    3. Layer-level Commands
    4. SmartGroup-level Commands
    5. Component-level Commands
  4. Events

Back to Top