Login

Learning & Support

Documentation

Advanced Scripting: Introduction

Twixl Support Team Updated: - Created :

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

2.1. Article-based app without a Hamburger Menu

For article-based apps without a Hamburger Menu:

  1. Tap the Gear Menu first
  2. Then select Advanced Filter Log
2.2. Article-based app with a Hamburger Menu

For article-based apps with a Hamburger Menu:

  1. Activate the Hamburger Menu first
  2. Select the Gear Menu
  3. Then select Advanced Filter Log

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

Was this article helpful?

0 out of 0 found this helpful