Conditional headers
- Applies to:
- All MindTouch Versions
- Role required:
- Admin
How the conditional header works
The dynamic custom header is a simple structure. The standard Expert header has code to determine if it should dynamically embed content from another page we call conditional headers.
The Header node in the example diagram would use DekiScript to:
- Get the page path, for example
success.yoursite.com/path/path/path
. - Determine if it should dynamically embed a conditional header.
- 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 an Expert template for each variation of the header.
- 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 Expert Support agent to get self-service branding setup.
- Create a separate page for each conditional header.
- 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.
- Navigate to Site tools > Dashboard > Site Adminisration > Template directory.
- Locate the custom header at Templates > Custom > Views > Header (Path:
/Template:Custom/Views/Header
) - 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.
- Use an
IF
statement to dynamically load one of the conditional headers. - 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
Expert 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:
- Create a developer and contributor group.
- Add users accordingly.
- Add the following DekiScript to your header template:
// 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'); }