Skip to main content
MindTouch Success Center

Conditional global variables

Applies to:
All MindTouch Versions
Role required:
Apply page or user conditions to your existing global variables.


Why set up conditional global variables?

Global variables already provide you with a quick and easy way to manage your documentation vocabulary across large quantities of content.  Conditional global variables provide an extra layer of flexibility and control to your global variables by giving you the ability to personalize their value based on the page they're on or the user that is viewing them.

How to declare your conditions

  1. Navigate to Site tool > Dashboard > Content management > Site Administration > Global Variables.
  2. Open the Variables page in Edit mode.
  3. Define the global variable value without conditions.
  4. Define the condition for the value as desired.

Condition examples

Condition Description Example
User group

You can use different user groups to control the conditional global variables for users.  For instance, different customer levels may have terms for the features or functions.  Example:

  • Standard = Mosarch
  • Premium = Mosarch+
  • Enterprise = Mosarch Pro
if (user.groups["enterprise"]) {
    export.productname = "Mosarch Pro";
User role MindTouch uses different user roles to control the level of engagement of your users. Typically, your customers are community members, and your colleagues are authors, editors, and administrators.  Authors, editors and administrators are all pro members and are considered "seated" users. Each uses one of your user licenses. You can condition terms based on whether users are seated or unseated.
if (user.unseated) {
    export.feature = "Super Search";
    export.feature = "search v4.2";
Page path When you create your content in MindTouch, it is crucial that you create your content using a hierarchy that is intuitive and navigable.  The MindTouch content framework makes setting up your structure easy. Once your structure is set up, you may want to use global variables that vary based on where your user is in the hierarchy.  
var pg = string.split(page.path,"/");
var root = pg[0];

if (root == "Beta") {
    export.version = "4.9 beta"
  • Was this article helpful?