Skip to main content

Make content appear and disappear

There might be situation where you want to display content on all pages exept of the home page. Because of page speed you want to check that before loading the content. 

Preparations

To be able to implement this we need to prepare a variable which we can use to ckeck if we currently are on the Home tab. How to:

  1. Open the theme-body.ascx file
  2. Scroll to the bottom of the file and search for the OnLoad function (See in the image on the right)
  3. Inside the function set these 2 lines of code:
    1. var portal = DotNetNuke.Entities.Portals.PortalSettings.Current;
    2. IsHome = portal.HomeTabId == portal.ActiveTab.TabID;
  4. After that you only have to set the variable outside the function:
    1. protected bool IsHome = false;

isHome will return true when the page that is beiing loaded is the Home tab and will return false on every other Page. 

You are finished this variable will be checked early enough in the loading process that it wont influence your page speed. And you can now use it to create conditions in your template.