DNN Text/HTML Replacement Tokens Options
Starting with DotNetNuke version 4.6.0 a new feature was added to the Text/HTML module that allows you to use replacement tokens inside your content. This is something that many people do not even notice and was not highly publicized at the release of 4.6.0. This article will first of all show you the different settings available and the differences between them, then it will show you how the tokens can be used, and to finish up a quick discussion on performance implications will be completed as well.
The Settings
Below are the settings made available via the “Settings” option for all instances of the Text/HTML module.
The default option is “no Replace”, this option provides a Text/HTML module that functions just like all other instances of the module had functioned before. Limited replace provides you with just a few replacement options, and is great if you simply want to inject the portal name, date or time. Lastly enhanced replace will allow you to customize content based on other objects such as the user information or module information.
For tokens to be replaced you must select an option other than “no Replace” in the settings. The downfalls of using token replacement will be discussed in detail at the end of this article
Using the Tokens
Using the tokens is very easy and follows the standard token schema used elsewhere in DotNetNuke. A token is defined inside a set of [] characters, for example to display the portal name you would use [Portal:PortalName]. This is great for those easy to remember tokens, but one item that many people request is a listing of all tokens. This is not something that is provided by the Text/HTML module, however the UDT module has a listing. Below is a copy of that listing for your reference.
| Token | Description |
| [Portal:Currency] | Currency String |
| [Portal:Description] | Portal Description |
| [Portal:Email] | Portal Admin Email |
| [Portal:FooterText] | Portal Copyright Text |
| [Portal:HomeDirectory] | Portal (relative) Path of Home Directory |
| [Portal:LogoFile] | Portal Path to Logo file |
| [Portal:PortalName] | Portal Name |
| [Portal:PortalAlias] | Portal URL |
| [Portal:TimeZoneOffset] | Difference in minutes between Portal default time and UTC |
| | |
| [User:DisplayName] | User’s Display Name |
| [User:Email] | User’s Email Address |
| [User:FirstName] | User’s First Name |
| [User:FullName] | [deprecated] |
| [User:LastName] | User’s Last Name |
| [User:Username] | User’s Login User Name |
| | |
| [Membership:Approved] | Is User Approved? |
| [Membership:CreatedDate] | User Signup Date |
| [Membership:IsOnline] | Is User Currently Online? |
| | |
| [Profile:<Property>] | Use any default or custom Property defined for user profiles as listed in Profile Property Definition section of Manage User Accounts. Please use non-localized Property titles only. |
| | |
| [Tab:Description] | Page Description Text for Search Engine |
| [Tab:EndDate] | Page Display Until Date |
| [Tab:FullUrl] | Page Full URL |
| [Tab:IconFile] | Page Relative Path to Icon file |
| [Tab:KeyWords] | Page Keywords for Search Engine |
| [Tab:PageHeadText] | Page Header Text |
| [Tab:StartDate] | Page Display from Date |
| [Tab:TabName] | Page Name |
| [Tab:TabPath] | Page Relative Path |
| [Tab:Title] | Page Title (Window Title) |
| [Tab:URL] | Page URL |
| | |
| [Module:Description] | Module Definition Description |
| [Module:EndDate] | Module Display Until Date |
| [Module:Footer] | Module Footer Text |
| [Module:FriendlyName] | Module Definition Name |
| [Module:Header] | Module Header Text |
| [Module:HelpUrl] | Module Help URL |
| [Module:IconFile] | Module Path to Icon File |
| [Module:ModuleTitle] | Module Title |
| [Module:PaneName] | Module Name of Pane where UDT resides |
| [Module:StartDate] | Module Display from Date |
| | |
| [DateTime:Now] | Current Date and Time |
| [Ticks:Now] | CPU Tick Count for Current Second |
| [Ticks:Today] | CPU Tick Count since Midnight |
| [Ticks:TicksPerDay] | CPU Ticks per Day (for calculations) |
You can use any combination of these tokens to provide your new display. For example if I want to display text welcoming a user to the site and letting them know the current date and time. I would use enhanced replacement and when editing the text I would have the following text.
When logged in as a host user I would see the following text
Using this example you can see how you can create dynamic content that will customize messages for users or different portals with ease.
Downfalls to Using Replacement Tokens
As with most things there is always a down side to a positive item, there is no exception when talking about replacement tokens inside the Text/HTML module. Even though the tokens are a great feature they do have two major downfalls. The first is that when using tokens inline editing is disabled. For most users this is not an issue, you simply have to use the “Edit Text” link to edit the content of the module.
The other downfall of token replacement is that if enabled ALL caching for the module is disabled, this means that each page request will result in a direct query to the database, parsing of the text, and then display. By default Text/HTML content is cached for 20 minutes, if you enabled token replacement every request will generate the content new. In smaller sites this is not an issue, but in high activity sites, this additional database and server traffic can have an effect on site performance, therefore it is cautioned that you should ONLY enable this functionality when it is needed.
This should serve as a good overview on how replacement tokens and the Text/HTML module work. You will need to experiment with the token listing to truly experience the flexibility that you can have with token replacement.