DotNetNuke, ASP.NET, Web Development Blog

DotNetNuke- Code Tokens

Quick tips for getting more from your skin.

Here's a compilation of tips and tricks for getting at more than just <%= SkinPath %> in your DNN skin.

To show the name of the Portal:
<%= PortalSettings.PortalName %>

To get the current portal's home directory (i.e. /portals/0 ) you would use:
<%= PortalSettings.HomeDirectory %>


To get the ID of the tab/page:
<%=PortalSettings.ActiveTab.TabID %>

To get the Title of the tab/page:
<%=PortalSettings.ActiveTab.Title %>

To get the Name of the tab/page:
<%=PortalSettings.ActiveTab.TabName %>


To display the name of the Active Page's Root-level Parent:

For the Active Page's immediate Parent Tab Name you could try this:
<%=PortalSettings.ActiveTab.BreadCrumbs(PortalSettings.ActiveTab.Level - 1).TabName %>
However, if this code is on a root-level page, DNN gives an 'out of range' exception.  So instead you could test first for the root-level case:
    If PortalSettings.ActiveTab.Level > 0 Then
        Response.Write(PortalSettings.ActiveTab.BreadCrumbs(PortalSettings.ActiveTab.Level - 1).TabName)
    End If

Another feature that is not widely known is that you can create a link to a tab by just knowing the name of the tab/page:

<a href="/?tabname=store">Store</a>
Beware that if there is a page also named "store" in the recycle bin that this will fail.  The tabname parameter will only work if there is only one tab with that name.  For example, if there is one in the recycle bin and one that has not been deleted, or if there is one with the same name under a different parent, and you can't make it unique then you will have to use the tabID instead.
<a href="<%=NavigateUrl(36)%>">Store</a>

To create a hyperlink, within or surrounding the logo to return to the home page, just use the domain name without any page and let the system pull up the default page:
<a href="">LOGO</a>
Another way would be like this:
<a href="/?tabid=<%=PortalSettings.HomeTabId%>">LOGO</a>
But that would only be if you had the Home tab set in site settings.


Leave a Comment
Email: (not displayed)

Enter the code shown above:

Return to previous page