Skip to main content
MindTouch Success Center

Configure conditional headers

This page applies to:MindTouch (current)

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. 
 

Understand how the conditional header works


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

For instance, the Header node in the diagram to the left 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 create conditional headers, follow the steps below.

Step 1: Structure your conditional header template

Screenshot of header template in templatesTo configure your conditional header, you will need to 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.  

  1. Create a separate page for each conditional header. (The screenshot on the right shows the header template structure for success.mindtouch.com.) 
     
  2. 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. 


Step 2: Navigate to the custom header template

  1. Navigate to Site tools Dashboard > Content ManagementTemplate directory.  
  2. Locate the custom header at Templates > Custom > Views > Header    (Path:   /Template:Custom/Views/Header)
  3. Add HTML, CSS, JavaScript and DekiScript to your custom header to create a dynamic layout. 
     

Step 3: Dynamically display your conditional header

Display a header for different paths

Once you have set up your conditional header template structure, begin to wire up the logic:

  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?