About the SCS Object

The controller JavaScript uses variables and properties defined in the global SCS object in order to render the web page. The global JavaScript object must be defined in the controller file before the inclusion of the controller.js file. There are two primary properties in the SCS object that can be used for customization:

SCS.sitePrefix

The SCS.sitePrefix variable defines the path prefix of the online site. Normally this defaults to site/<siteName>/.

The controller JavaScript uses this value to determine what web page to display. For example, if the browser is requesting the page at /site/SampleSite/products/index.html, the sitePrefix /site/SampleSite/ allows the JavaScript to compute that the products/index.html page in the site should be displayed. Note that the sitePrefix must be a string value that begins and ends with a "/" character.

If a proxy or other infrastructure such as Akamai and URL mapping rules are in place, modifying this variable allows the site prefix to be customized. For example, setting the sitePrefix to /intranet/ExampleSite/ would allow the web site to be delivered with that pathname in the browser instead of the default /site/SampleSite/ path prefix.

Note:

Internally the default controller JavaScript uses "/" as the sitePrefix if the URL in the browser does not match the site prefix. This allows the site to be served using a vanity domain without customization.

SCS.preInitRendering

If defined, the SCS.preInitRendering function is called by the controller JavaScript code before any of its computational logic executes. This is a useful function to define in custom controller files to override basic operations of the controller JavaScript.

If defined, SCS.preInitRendering must be a function. It is called without any arguments, and no return value is expected or processed.

SCS.getDeviceInfo

The SCS.getDeviceInfo function allows customization of the device detection logic inside the controller JavaScript. This detection is used to determine if a mobile or responsive version of a page should be delivered.

The SCS.getDeviceInfo function does not take any arguments, and it returns a JavaScript Object having two properties:

  • isMobile—a Boolean property indicating that the current device is a mobile client, like a smart phone.

  • isIOS—a Boolean property indicating that the current device is running on an iOS-based operating system.

If the custom controller does not override SCS.getDeviceInfo, the built-in default implementation is used.