Start page / Template development / JavaScript APIs / Multi Perspective Preview

MPP_API: JavaScript API for Multi Perspective Preview

JavaScript object: top.MPP_API
Access API documentation: MPPWebControl

The Multi Perspective Preview JavaScript API is available via the JavaScript object top.MPP_API and provides several functions that allow access to the current time and custom parameters set in the MPP toolbar.

Important The MPP JavaScript API does not provide information about the current viewport setting.

Identifying MPP State

boolean isParameterized() indicates whether MPP parameterization is active (true; the MPP toolbar is displayed in the user interface) or not (false; the MPP toolbar is not displayed).

Obtaining Parameters Set in the MPP Toolbar

The following functions provide information about the values currently set in the MPP toolbar. This allows dynamic adjustment of content in the preview to match these MPP settings, e.g. displaying certain HTML elements based on the currently selected date in the timeline or the currently active visitor role in custom MPP parameters.

JavaScriptObject getTimeParameter() provides the current date and time set in the MPP timeline.

Object getParameter(String name) provides the current value of the custom preview parameter. The parameter name indicates an input component with a matching name attribute in the page template used for MPP parameterization.

Setting Parameters in the MPP Toolbar

While working in the preview, it may become necessary to adjust MPP parameters, e.g. because the visitor role changes from "not logged in" to "logged in". The following functions allow setting MPP parameters so that the toolbar reflects the current state of the preview.

void setTimeParameter(JavaScriptObject date) sets the provided date and time in the MPP timeline.

void setParameter(String name, Object value) sets the value of the custom preview parameter in the MPP toolbar. The parameter name indicates an input component with a matching name attribute in the page template used for MPP parameterization, while the parameter value must be an object compatible with that input component's value type.

Using MPP in SiteArchitect: Querying the time of injection

If you use the MPP JavaScript API in SiteArchitect you should wait until it is injected. You can use the following instruction for this:  

<script type="text/javascript" language="javascript"> 
<!--
function anyFunction() {
// PUT YOUR CODE HERE
}
$CMS_IF(isWebEdit)$
anyFunction();
$CMS_ELSE$
window.onBrowserInjection = function(name, object) {
if (name == "MPP_API") {
anyFunction();
}
}
$CMS_END_IF$
-->
</script>

© 2005 - 2024 Crownpeak Technology GmbH | All rights reserved. | FirstSpirit 2024.12 | Data privacy