Creating Login & Register links in DotNetNuke
October 27th, 2009, Erik HindsSometimes you may want to use a text/html module to display login and register links to unathenticated users. This is actually quite easy using the standard text/html module, with token replacement turned on.
- Start by adding a new text/html module to your page.
- In the module settings, change the display to “Unauthenticated Users”.
- In the module settings, check the box for “Replace Tokens” at the bottom of the form, click update.
- Select Edit Text (or Edit Content) and switch to the source (HTML) view. Paste in the code below:
<p>To view this section, you must be a registered member of this site.</p>
<a href=”[Tab:FullUrl]?returnurl=[Tab:FullUrl]&ctl=login”>Login</a>
<a href=”[Tab:FullUrl]?returnurl=[Tab:FullUrl]&ctl=register”>Register Now</a> - Click update.
The important parts to these links are the current tab url token [Tab:FullUrl] and specifying the ctl parameter. The former builds the link and tells the register/login forms where to redirect after submission. The latter loads the page with only the appropriate control, stripping out all other modules that would normally be on the page. This snippet can be used on any page on your site, since it’s dynamically grabbing the page/tab URL.
These are just some of the users for the token replacement engine in the text/html module, which can turn a normally static module into something a little more dynamic.
Here are some more tokens that can be utilized:
| 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) |