Table of Contents

LookUp System

you are here (click to zoom) - discover the stack

Many things in the EAV and 2sxc require it to look up parameters. Examples could be:

  1. The current Page ID
    to then find metadata for this page
  2. The current Date to filter out news items which should be published in future
  3. An Id from the URL Parameters to show details about this id

This is done using Tokens which look like [QueryString:Id]. To achieve this 2sxc has three parts:

  1. Tokens which parses the placeholders
  2. The LookUpEngine which will get the values...
  3. ...using LookUp Sources to really resolve the values.
Tip

The LookUp System is used in Queries and Token Templates. But since Token-Templates are fairly trivial, we recommand that you only use Tokens for Queries and instead create your Templates using Razor.

Example Without LookUp

Imagine a Query which has an EntityId Filter which expects an ID. This could be hardwired like this:

What happens now is as follows:

  1. The EntityId-Filter will pass all the settings to be parsed by the LookUp-Engine
  2. The LookUp-Engine will detect that it's a simple value (not a Token) and just return the 38654
  3. The EntityId-Filter will then do it's job and retrieve this item

Example With LookUp

But it would make more sense if the ID were to be dynamic, maybe from the URL like this:

What happens now is as follows:

  1. The EntityId-Filter will pass all the settings to be parsed by the LookUp-Engine
  2. The LookUp-Engine will detect the Token and parse it
  3. Since the first part in the token says QueryString the LookUp-Engine will check if it has a LookUp-Source by that name
  4. Since it has a LookUp which answers to QueryString, it will ask this source if it can resolve id
  5. Assuming that the page has ?id=38654 then the LookUp will say yes! it's 38654
  6. The EntityId-Filter will then do it's job and retrieve this item

Discover More

  1. The Token Syntax and all the features
  2. LookUp Engine
  3. LookUp Sources
  4. Query LookUps
  5. Token Template LookUps

For example, when a Query is created, it may need to know the current PortalId or the current time, to properly filter/sort something.

This is achieved through 2 special object types, the ToSic.Eav.LookUp.ILookUp and ToSic.Eav.LookUp.ILookUpEngine, both in the ToSic.Eav.LookUp namespace.

Also Read

History

  1. General Tokens introduced in 2sxc 1.0
  2. Most enhancements were in 2sxc 07.00