With Advanced Scripting you can add conditions to a Content Item or a Collection
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. This is a paid option. See Specs & Pricing for more info.
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?
ENTITLEMENT PACK REQUIRED:
To use the Advanced Scripting functionality, you need to have the Entitlement Pack activated. This is a paid option. See Specs & Pricing for more info.
Although Advanced Scripting is all about filtering Content Items and Collections, you define Advanced Scripting per Collection. As such you need to edit a Collection in order to adapt the Advanced Scripting to your specific needs.
The default script looks as follows:
// 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 Distribution Platform, below the Advanced Scripting editor window.
Debugging options
In a mobile article-based 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. This list can evolve, and new samples will be added along the way.
- 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