Table of Contents

Template Files

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

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

Template File Types

The system is built in a way, that furhter templating engines could also be implemented at any time. As of now there are two types of template files:

  1. Token (simple but limited)
  2. Razor (can do anything you can think of)

How it Works

Each View has a configuration referencing a template file. 2sxc will then decide what type it is, and run the appropriate engine.

The template files usually reside inside app root folder or sub folder. As of now, there are two types:

  • Razor / MVC - These always begin with an _ and end with .cshtml. Placeholders and code usually is marked with @ like @Content.Name
  • Tokens - these always end with .html. Placeholders usually look like [Content.Name]. Tokens cannot have any server-side code aside from the basic placeholders.
Tip

If your view just hosts a JavaScript SPA, it will also be one of these types of files.

Re-Using Templates

Note

Re-Using in many Views
Sometimes you'll want to use the same template file in multiple Views. This can just be configured at the View level

Tip

Re-Using Templates Across Portals
Instead of placing the template in the App-folder of the current portal, you can also place it in a global App-folder in the _default portal of Dnn. This is great if you have the same app in many portals, and want to centralize the template.

Tip

Razor Templates also support re-using template parts or any C# code. You can also pass parameters to these parts, which allows you to share template-code across templates.

Read also

History

  1. Introduced in 2sxc 1.0
  2. Automatic View-Polymorphism added in 2sxc 11