In the series Advanced Scripting Sample Apps we explain some use cases on how to use the Advanced Scripting. For more general info, it's very important that you read this KB-article first.
Preview with the Twixl App
You can preview this app by scanning the QR code with the Twixl app.
The test Entitlement-account you can use to test this behaviour:
-
Username:
test
-
Password:
test

Use Case
In this example, we show a Login button in the app when you are not entitled and a Logout button when you are entitled.
Instructions
Preparations
- Create a new app
- Setup Entitlements in the app (e.g. Print Subscribers)
- Add a Content Item to the Root Collection with the following properties:
- Type: Web Link
- Name:
login
- Link to URL:
tp-entitlements-signin://
- Add a Content Item to the Root Collection with the following properties:
- Type: Web Link
- Name:
logout
- Link to URL:
tp-entitlements-clear-token://
- Add a Content Item to the Root Collection with the following properties:
- Type: HTML Article
- Name:
whatever
- Set up your Advanced Scripting (see below)
Advanced Scripting Settings
For the Root Collection
// 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) { if (contentItem.Name == "login") { return !environment.IsEntitled(); } if (contentItem.Name == "logout") { return environment.IsEntitled(); } return true; } // Executed once for every collection after the filtering of the items function teardownFilter(collection, environment) { }