Skip to main content
MindTouch Success Center

Conditional headers

Conditionalize the header and footer of your MindTouch site with self-service branding. To display different headers or footers to particular users or on particular pages, follow the instructions in this article.

How the conditional header works

The dynamic custom header is a simple structure. The standard MindTouch header has code to determine if it should dynamically embed content from another page we call conditional headers.

Screenshot of dynamic header structure

The Header node in the example diagram would use DekiScript to:

  1. Get the page path, e.g.success.yoursite.com/path/path/path.
  2. Determine if it should dynamically embed a conditional header.
  3. Use a DekiScript function to load the conditional header. 


Example

If the page path is /Documentation, load the header at /Template:Custom/View/Header/Documentation.

Conditional headers are not supported on special pages such as search, login screen and password screen. Special pages only support one default header.

Configure your conditional headers

To configure your conditional header, create a MindTouch template for each variation of the header.

  1. Navigate to your header template.

    By default, your header template should be located at Custom > Views > Header. If you do not have a header template at this location, contact a MindTouch Support agent to get self-service branding setup.
     
  2. Create a separate page for each conditional header.

    Example screenshot shows the header template structure for success.mindtouch.com.
    Screenshot of header template in templates
  3. Add content into your header to indicate which header is loading.

    If you find yourself creating more than six templates, you may want to reconsider your approach. More than six conditional headers will be hard to manage and may have performance complications.
  4. Navigate to Site tools Dashboard > Content ManagementTemplate directory.  
  5. Locate the custom header at Templates > Custom > Views > Header    (Path:   /Template:Custom/Views/Header)
  6. Add HTML, CSS, JavaScript and DekiScript to your custom header to create a dynamic layout.

Dynamically display your conditional header

Create logic to display different headers for different paths or conditions.

  1. Use an IF statement to dynamically load one of the conditional headers.
  2. Add the following DekiScript to your header template.
// GET THE PAGE PATH AND SPLIT IT BY FORWARD SLASHES
// EXAMPLE PATH = /Documentation/Administration/Analyzing_Knowledge
// SPLIT PATH = [ "Documentation", "Administration", "Analyzing_Knowledge" ]
var current = string.split(page.path,"/");


// GET THE FIRST ITEM IN THE PATH LIST
var section = current[0];


// TEST THE CONDITIONS AND EMBED THE CONDITIONAL HEADER USING A TEMPLATE() CALL. 
if (#current && section == "Contact_Us")
{
   template("Custom/Views/Header/Contact_Us");
}
if (#current && section == "Documentation")
{
    template("Custom/Views/Header/Documentation");
}

Display a header for different users

MindTouch allows you to show a different header for users in different groups regardless of the page path. For example, your developer may need to access more technical resources than your administrative teams or you may want users in the contributor group to be reminded of your technical writing standards:

  1. Create a developer and contributor group.
  2. Add users accordingly.
  3. Add the following DekiScript to your custom header:
// TEST THE CONDITIONS AND EMBED THE CONDITIONAL HEADER USING A TEMPLATE() CALL.
if (user.groups["developer"])
{
    template("Custom/Views/Header/Developer");
}
if (user.groups["contributor"])
{
    template("Custom/Views/Header/Contributor");
}
  • Was this article helpful?