Skip to main content
Home  ›  Blog

Custom DataSource API - ConfigMask

DataSources often need settings which come from the App or from a settings dialog. The ConfigMask builds a configuration token which will be used to get this setting, and also ensures that cachings mechanims vary the cache based on the result of the configuration.

This is part of the new API for DataSources released in 2sxc 9.13.

How To Use ConfigMask

Here's a simple example of the constructor of the DnnFormAndList DataSource, which expects 3 settings:

Using ConfigMask in the FormAndList

public DnnFormAndList()
{
    // Specify what out-streams this data-source provides. Usually just one, called "Default"
    Provide(GetList);

    // Register the configurations we want as tokens, so that the values will be injected later on
    ConfigMask("ModuleId", "[Settings:ModuleId||0]");
    ConfigMask("TitleField", "[Settings:TitleFieldName]");
    ConfigMask("ContentType", "[Settings:ContentTypeName||FnL]");
}

This example adds 3 configuration masks - let's find out what exactly happens.

Tokens for Configuration Injection

The EAV-System has a sophisticated system to get configuration based on tokens. You can read about configuration injection using tokens in the wiki.

Registering and Resolving these Tokens with ConfigMask

Internally a lot happens, but you just need to know the ConfigMask command. The syntax is:

  • ConfigMask(key, mask)

This will do the following

  1. Add this mask (using this name) to the configuration list
  2. register this key to be cache-relevant

Next Steps

To use the values, you will also need to ensure that configuration is parsed. This is handled in the next blog

There is more to discover, for that, read the ConfigMask documentation in the wiki.

Love from Switzerland, 
iJungleboy


Daniel Mettler grew up in the jungles of Indonesia and is founder and CEO of 2sic internet solutions in Switzerland and Liechtenstein, an 20-head web specialist with over 800 DNN projects since 1999. He is also chief architect of 2sxc (see github), an open source module for creating attractive content and DNN Apps.

Read more posts by Daniel Mettler