Search code examples
dotnetnukedotnetnuke-7

How to link to the portal home page in a skin?


We have our own custom DotNetNuke 7 skin based on Bootstrap 3. It includes a navbar in which I want to have a navbar-brand that links to the home page.

Is it possible to generate a link to the portal home page inside a skin?

On the documentation page I found a link to the Skin Objects Guide (pdf) suggesting [Portal:url], which I tried like this:

<a href="[Portal:url]" class="navbar-brand">Home</a>

Not surprisingly this doesn't work (the pdf is from 2009). The other links from the wiki are either dead or useless.

I've also tried looking through the "Gravity" and "Aphelia" skins that come with DotNetNuke, but nowhere do the ascx files seem to link to the portal home page.

Obviously I've also tried GoogleFu in various forms, e.g. "DotNetNuke skin create link to home page", but this leads nowhere.

Anyone know how to do this? Or much preferred even: where I could've found this- and related info? Or am I doomed to dive into the source code of DNN?


Solution

  • It's dangerous to go alone. Take this:

    <a href="<%= DotNetNuke.Common.Globals.NavigateURL(PortalController.GetCurrentPortalSettings().HomeTabId) %>" class="navbar-brand">Home</a>
    

    NavigateUrl is your goto method to handle referencing another part of your portal. It goes through url rewriting so it will be consistent with the rest of your urls.

    There a plenty of signature overloads for this function, where you can specify keys, controlkey, settings, etc. Have a look at the DotNetNuke.Common.Globals class for more info.

    Note that if you use the abovementioned version, you'll need to have a "Home" page set for your portal under admin > site settings.