Table of Contents

Token Templates

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

Token Templates will generate HTML - often based on the data a editor entered, and/or which was provided from the App.

Note

The View determines which template file is being loaded.

Tip

Token templates are by far not as powerful as Razor Templates. We always recommend Razor.

Example Template

<h1>[Header:Title]</h1>
<ul>
  <repeat>
    <li><a href="[Content:Link]">[Content:Title]</a> [Content:Toolbar]</li>
  </repeat>
</ul>

How it Works

Token templates use a Token Engine to generate Html. The convention uses placeholders like [Scope:Property] to put data into the Html.

The template files usually reside inside app root folder or sub folder. These end with .html. Placeholders and code usually is marked with [...] like [Content:Name].

Internally the Token-Engine uses LookUps to find what can be shown.

Tip

Tokens are very limited, we strongly recommend to use Razor Templates templates instead.

Read more about it in the Token Basics

Content, Presentation and Toolbar Tokens

  1. [Content:PropertyName] like [Content:FirstName]
  2. [Content:Presentation:PropertyName] like [Content:Presentation:UseLightbox]
  3. [Content:Toolbar] to get a Toolbar for the Content-object with it's Presentation

Token Toolbars only support the basic toolbar, not the newer TagToolbar. Read more about Toolbars.

Header Tokens

Note that in Token-templates the Header is called the ListContent for historical reasons, not Header like in Razor.

  1. [ListContent:PropertyName] like [ListContent:Title]
  2. [ListContent:Toolbar] for the toolbar
  3. [ListContent:Presentation:PropertyName] like [ListContent:Presentation:UseLightbox]

Common LookUp Sources

  • App Sources
    1. App - the current App, which can give you folders (to link JS files) ☢️🩸
    2. App:Settings - app settings ☢️🩸
    3. App:Resources - app resources, translated labels etc. ☢️🩸
  • Web Server and System Sources Hybrid
    These work both on Dnn and Oqtane (2sxc 12+)
    1. [Query] ☢️🩸
  • Web Server and System Sources
    1. QueryString - url parameters ☢️
    2. Form - form post parameters ☢️
    3. DateTime - current date/time information ☢️🩸
  • CMS / Dnn Sources
    1. [Site]
    2. [Page]
    3. [Module]
    4. Portal - the current Dnn portal
    5. Tab - the current Dnn page
    6. Module - the current Dnn module
  • User Information Sources
    1. User
    2. Membership
    3. User Profile

Read more about LookUp Sources

Repeaters / Lists

Token templates have a trivial mechanism to loop through lists. Note that we strongly recommend you use Razor Templates instead. Here's how it works:

<ol>
  <repeat repeat="Item in Data:Default">
    <li>
      [Item:Title] [Item:Toolbar] <br>
      <a href="?details=[Item:UrlKey]">Details...</a>
    </li>
  </repeat>
</ol>

In a repeater the Toolbar can be added using [repeater-name:Toolbar].

Read also

History

  1. Introduced in 2sxc 1.0