About My Tokens‎ > ‎

Core Tokens

My Tokens inherits all tokens from DotNetNuke. Additionally, it adds several new predefined types (such as access to application collections) and custom tokens (for example against Database or HTTP Requests).

My Tokens Core Tokens

Besides the dynamic tokens, My Tokens also comes with more useful predefined tokens. Most of these are bound directly to collections from Asp.NET, such as Request.QueryString, Application, Session, etc. In the Values column below, Key represents the entry name in this collections, so if there's a Application["MyName"] = "John", then you can display it with [Application:MyName]. Other tokens are inherited from standard DotNetNuke tokens.

Token Source Token Description Values
Binds HttpApplicationState collection [Application:<Key>]
Browser Binds HttpBrowserCapabilities properties. For example, [Browser:IsMobileDevice] evaluates to true when the user is using a mobile phone.[Browser:<Key>]
ServerVars Binds Request.ServerVariables collection [ServerVars:<Key>]
Session Binds HttpSessionState collection [Session:<Key>]
Cookie Binds HttpCookieCollection [Cookie:<Key>]
Get or
Binds Request.QueryString collection [Get:<Key>]
Post Binds Request.Form collection [Post:<Key>]
Params Binds Request.Params collection [Params:<Key>]
HttpContextItemsBinds HttpContext.Items collection [HttpContextItems:<Key>]
Random Returns random text from comma delimited list of values
Values can contain other tokens

User Roles
Offers access to the roles assigned to current users.
Tokens available are: All (returns comma separated string with all roles of current user).

UrlOffers access to various parts of the URL: Domain (e.g. example.com), Domain Root (e.g. http://example.com:8032), Full Url (e.g. http://example.com/page), Relative (/page), PageName (e.g. PageName.aspx) and PageNameWithoutExtension (e.g. PageName)[Url:Domain], [Url:Port], [Url:DomainRoot], [Url:FullUrl], [Url:Relative], [Url:PageName],
[Url:Referrer], [Url:Query],

 This token computes a portal URL give a tab id or tab path. For example [NavigateUrl:123] or [NavigateUrl:/mypage]. This is very useful when having to hardcode portal URLs in various places like HTML modules, so for example when page hierarchy or page names change, the URLs propagate automatically.

[NavigateUrl:<tab id>]
[NavigateUrl:<tab path>]
ModuleOutputPulls the content of a module identified by its module ID to embed them at current location. The module is fetched using the an HTTP request to the module print page. So make sure the application pool is allowed to make HTTP requests to itself. Sometimes the DNS is not configure properly on the machine, which can't resolve itself. To implement a caching strategy, create a custom Constant Token and use this token within the definition of the constant token. This will give you all the caching options that custom tokens have.

[ModuleOutput:<module id>]






Sets a value in user profile, session or cookie. The value is actually taken from the default value (an option of most tokens), which follows after equal sign. So for example, [SetProfile:ThisUserId=[User:Id]] will set the current user ID in the session under ThisUserId key.

Set cookie accepts further parameters:
  • NonPersistent - set to true so the cookie does not persist
  • Expires - set to a date time when to expire the cookie. For example 2016-05-05

Important! SetProfile, SetSession and SetCookie tokens are write only. They always return empty strings. Use other forms below if you need to also return values.

These are special Token Sources that interrogate two sources for content and synchronizes them. These are available starting with My Tokens 1.6.2,

Let's take for a example the [GetOrSession:MyParam] token. When invoked, My Tokens runs the following algorithm:
    1. If MyParam exists in GET
            => save the value in Session:MyParam
            => return the value
    2. If MyParam doesn't exist in GET, check Session:MyParam
            => if exists, return value from Session:MyParam
            => if doesn't exist, return default value or empty string

So, basically, My Tokens takes care of saving page parameters so they can be used at later stages when the page state no longer can be accessed.

Same as previous tokens, except these initialize a setting if it doesn't exist using a value provided through a parameter - so they are basically a generalization of tokens above.

For example,  
[SessionOrInit:<Key>(InitValue="<My Initial Value>")]

If the key already exist in session, the InitValue is ignored, unless you specify the UpdateAlways parameter with value "true". For example [SessionOrInit:<Key>(InitValue="<My Initial Value>", UpdateAlways=true)] 





Checks either current user has or doesn't have a role. By default, these tokens return true or false, but they can be adjusted using the format specified and default value to return something else. For example, [HasRole:Customer='Not Customer'|'This is a customer'].

IfThis token compares 2 values and return true if they are equal or false otherwise. The values are passed in as parameters a and b. For example, [If:Eq(a="test", b="test")] will return true.
If:DisplayIfNotEmpty returns a text when a condition is not empty.
[If:Eq(a="...", b="...")]
[If:Equals(a="...", b="...")]
[If:DisplayIfNotEmpty(Condition = "", DisplayText = "show this")]

GuidThis token generates guids. The 2 form lets you choose between having hyphens or not. I.e. 03311958-433f-4d7e-bd2d-086f8c07621f or 03311958433f4d7ebd2d086f8c07621f.

Base64Decode - Removed

 These tokens encode or decode a string to or from base64. [Base64:Encode(Value='<encode string>')]
[Base64:Decode(Value='<base64 string>')]
[Base64Decode:<decode string>]
EncodeSql - Obsolete, replaced by Sql This token sanitizes an SQL script against SQL injection.   

[EncodeSql:<sql script>]
 Sql This token sanitizes an SQL script against SQL injection.    [SQL:Encode(Value='<sql string')]
SiteAdmin Return the administrator user. This has the same properties like the [User:*] token.

[SiteAdmin:<user property>]
User In addition to the standard user tokens (described below), My Tokens adds the following:
  • [User:AvatarUrl] outputs the URL to current user profile picture.

  • User:Avatar] - outputs the user profile image, including the HTML img tag. This is because the HTML editor would usually mess with the img tags so the URL is relative to the portal root. So if you were to write <img src="[User:AvatarUrl]" /> this will get transformed on save into <img src="/Portals/0/[User:AvatarUrl]" /> which would obviously not work. The workaround is to use this [User:Avatar] token.
Normally, the User token returns information about currently logged in user. But My Tokens allows passing in a parameter that would determine whose information is retrieved. This can be passed as a user id, username or an email address. The following show all three scenarios:
  • [User:FirstName(userid=111)] - outputs the first name of the user whose ID is 111
  • [User:FirstName(username="elvis")] - outputs the first name of the user with username 'elvis'.
  • [User:FirstName(email="elvis@hb-hotel.com")] - outputs the first name of the user found to have the respective email address. If more users have the same address, the first one is used.

[String:Replace(Input="25 feb 2015", Match="25", Replacement="01")] => 01 feb 2015

[String:Replace(Input=<text>, Match=<text>, Replacement=<text>)]

  [String:RegexReplace(Input="25 feb 2015", Match="\d{2}", Replacement="01")] => 01 feb 0101 [String:RegexReplace(Input=<text>, Match=<text>, Replacement=<text>)]

  [String:RegexMatch(Input="25 feb 2015",Match="\d{2}")] => 25

[String:Substring(Input="25 feb 2015",Start=0,Length=2)]
 [String:RegexMatch(Input=<text>, Match=<text>)]

[String:Substring(Input=<text>, Start=<number>, Length=<number>)]

How To Use The Tokens With Persistence

DotNetNuke Inherited Tokens

These are tokens that are supported by DotNetNuke token replacement system. They have been included in this documentation for quick reference.

Note that these tokens don't exist in all versions of DNN and also they may be restricted or behave differently in each version. Please check DNN specific version documentation for more information.

Token Source Token Description Values
Host Binds HostSettings information [Host:<HostSetting>] - where HostSetting is defined in the HostSettings table
Portal Binds information about current portal [Portal:Currency], [Portal:Description], [Portal:Email], [Portal:FooterText], [Portal:HomeDirectory, [Portal:LogoFile], [Portal:PortalName], [Portal:Url], [Portal:TimeZoneOffset], [Portal:CurrentLanguage] (My Tokens only)
User Binds information about current user [User:VerificationCode], [User:AffiliateId], [User:DisplayName], [User:Email], [User:FirstName], [User:IsSuperUser], [User:LastName], [User:PortalId], [User:UserId], [User:Username], [User:FullName], [User:Roles]
Membership Binds membership information [Membership:Approved], [Membership:CreatedDate], [Membership:IsOnline]
Profile Binds profile information for current user [Profile:<ProfilePropertyName>]
Tab Binds information for current page [Tab:Description], [Tab:EndDate], [Tab:FullUrl], [Tab:IconFile], [Tab:KeyWords], [Tab:PageHeadText], [Tab:StartDate], [Tab:TabId], [Tab:TabName], [Tab:TabPath], [Tab:URL]
Module Binds information for current module [Module:Description], [Module:EndDate], [Module:Footer], [Module:FriendlyName], [Module:Header], [Module:HelpUrl], [Module:IconFile], [Module:ModuleID], [Module:ModuleTitle], 
[Module:PaneName], [Module:StartDate]
DateTime Binds DateTime information [DateTime:Now]
Ticks Binds ticks information [Ticks:Now], [Ticks:Today], [Ticks:TicksPerDay]

Other tokens

There is a list of tokens that return the Geo IP location using Free Geo IP service:











Portal Globally Unique Identifier

[Portal:Guid] -
to return the GUID of the current side
[Guid:New] - unique guid - it generates a new GUID every time is called