Parameters for the DataSources and the Query
DataSources are parts of a query, and each performs certain functions. To do this, it needs parameters which it can get from many sources
- The Configuration-UI of this specific Data
- The general Query-Parameters
- Various Look-Up Sources (Tokens)
- Other DataSources which give the configuration value on an In-Stream
Configuration UI of a Part = Settings
Each part is a DataSource. If it's configurable you'll see a button appear when you mouse over it like this:
The dialog which appears will be different for each type of DataSource. In the C# code of the DataSource, these parameters are available as Settings.
Configuration can be Values or Tokens
Almost all configuration values are strings, even if the DataSource expects a number. This allows you to write either
[QueryString:Id] depending on your needs. Here's an example:
Queries can be parameterized with token placeholders like
To understand these placeholder tokens, best read up on LookUp Tokens Explained. There you'll read about how tokens work, where they come from, how to use default/fallback values and more.
Aside from the normal LookUps like
User etc. there are two special LookUps which you should know about: Params and In.
Global Query Parameters with Params-Token
Each Query can have a list of Parameters which all parts can access through the Params LookUp. This has some great benefits:
- A developer can always see what parameters affect the Query
- If you use the same parameter in various places, you can be sure that it's always the same value.
- These Parameters can also be set from another query calling it
This is what it looks like in VisualQuery:
You will find a full explanation of this here: Params LookUp in Query Parameters.
You can write the tokens you need like
[QueryString:Id] directly into any DataSource configuration.
But we highly recommend that you create a param for it and use that instead. It just makes it easier for people looking at your query to see what will affect its results.
Get Configuration from Another DataSource
Often some stored data will be used to change what a DataSource does. Here's an example which will retrieve a Category either pre-defined or from the URL, then use that category to apply a filter:
Here's how the settings of that are configured:
Read more about the In LookUp.
Settings from the Current Module (CmsBlock)
Another common use case is when a normal Module-Content provides more settings. This uses the CmsBlock DataSource:
This shows how the In will look in the
Mod stream to find the
PortalId. Read more about this
Test your Query with Test Parameters
- Introduced in 2sxc 07.00
- In added in 2sxc 07.00
- Params added in 2sxc 10.22