Settings & API Hooks

Details on using the Expression Key Value store and integrating extra behaviour to APIs via API Hooks.

Expression contains a Key-Value store for JSON data. This system can be used to provide global variables which are available in your code assets.

They are also used to manipulate core behavior of Expression.

Each setting has a Namespace, Key, Value and an Export To Code option.

Built-in Settings

API Hooks

The majority of Expression APIs are CRUD APIs. Each CRUD API exposes hooks. This allows you to respond to data object changes globally.

Each Hook setting is an array of bundlePaths saying which serverside script you want executed and in what sequence.

Hooks are listed in the ApiHooks namespace.

Example Binding:

ApiHooks Article.postAdd = ["HookScripts/NotifyOnArticleCreate"]

Custom Payment Gateways

If your Expression installation is E-Commerce enabled, you can provide a special type of Serverside Module to implement a Credit Card Payment Gateway.

Example Binding:

Store PaymentGateway-bundlePaths = [ "GatewayModules/Test", "GatewayModules/Live" ]

These options will show in the UI alongside the builtin Expression gateways for selection.

Creating Settings


Creating settings is done in the Expression UI in the Global Configuration section of the Settings module. Simply define the Namespace, Key and Value you desire and save the setting. Note that Values must be valid JSON.

Settings can be created programatically via the XprApi.

Accessing Settings


With the Export To Code option enabled on a giving setting, the setting becomes available in your code assets.

Exported Settings are available as part of the xpr context, under xpr.settings, and are globally usable in Datasource configs as well as ViewTemplates.

In server side scripts they are accessed via the readonly XprSettings object.

var settings = new XprSettings();
var value = settings["Namespace"]["Key"];