With Advanced Scripting you can decide to filter Content Items or Collections based on selected criteria.
1. Advanced Scripting, what is it?
Using Advanced Scripting, you can link a number of properties available in the app (bundle ID, language, geolocation, ...) and decide whether the Content Item or Collection should be visible or not.
ENTITLEMENT PACK REQUIRED:
To make use of the Advanced Scripting functionality, you need to have the Entitlement Pack activated. Contact the sales department for details.
2. General info about Advanced Scripting
Advanced scripting is a collection of JavaScript functions that will be evaluated for each collection and/or content item in the context of an application.
It can be used to filter the content items shown in a collection based on a custom set of business rules.
Where can I activate Advanced Scripting?
Although Advanced Scripting is all about filtering Content Items and Collections, you define Advanced Scripting on a Collection level. As such you need to edit a Collection in order to add a script.
Her's a sample script:
// Executed once for every collection before the filtering of the items
function setupFilter(collection, environment) {
}
// Executed for once for every collection
function shouldShowCollection(collection, environment) {
return true;
}
// Executed for every single content item
function shouldShowItem(contentItem, collection, environment) {
return true;
}
// Executed once for every collection after the filtering of the items
function teardownFilter(collection, environment) {
}
IMPORTANT:
Each of the 4 base functions that get executed in the advanced filter currently have a maximum execution time of 2 seconds.
TIP:
You can find a complete syntax and lifecycle overview here. This info also can be found on the Twixl platform, below the Advanced Scripting editor window.
Debugging options
In a mobile app
In the Browser Client
For The Browser Client, you need to add the suffix ?debug=1 and then you'll notice the debugger icon in the toolbar.
So this means, if your Browser Client url is:
https://browserclient.twixlmedia.com/<app>
Then you'll need to add ?debug=1 in the following way:
https://browserclient.twixlmedia.com/<app>?debug=1
3. Advanced Scripting Sample Apps
INFO:
We've created several Advanced Scripting Sample Apps for you, each with a specific case that could be useful. They are a good start to explore the immense list of possible scenarios for Advanced Scripting.
- Advanced Scripting | Sample App 1: Login / Logout Button
- Advanced Scripting | Sample App 2: Different content for phone vs tablet vs Browser Client
- Advanced Scripting | Sample App 3: Using twxlog
- Advanced Scripting | Sample App 4: Using JSON and XML
- Advanced Scripting | Sample App 5: Using twxhttp
- Advanced Scripting | Sample App 6: Custom Vars
- Advanced Scripting | Sample App 7: Multiple Languages
- Advanced Scripting | Sample App 8: Privacy Policy