Zum Inhalt springen

Make content appear and disappear

There might be situations where you want to display content on all pages except the home page. For page speed reasons, you want to check this before loading the content.


Preparations

To implement this, we need to prepare a variable that we can use to check if we are currently 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 the image on the right).
  3. Inside the function, add the following two 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 being loaded is the Home tab, and will return false on all other pages.

You can now use it to create conditions in your template.