Skip to main content
MindTouch Success Center

Create custom conditional text blocks

This page applies to:MindTouch (current)

Conditional text blocks in MindTouch allow you to control which of your users have access to which information. Learn how to create custom conditional text blocks for specific groups to control your proprietary among your internal users. 

Implementation of conditional content for specific groups requires some coding experience. Keep in mind that while conditional content will be displayed to the respective users, this content is not searchable within MindTouch.

How to create conditional text blocks

Step 1: Create groups

Once you have identified our groups, create your groups (Editors and Administrators, in this example).

If your groups are already set up in your system or are synchronized from an external authentication provider, then you don't need to recreate them to set up conditional text blocks.  

Step 2: Test your conditional classes

This section requires some DekiScripting. The example below checks if the person accessing the article is in the Administrators group:

  1. Create a New page.
  2. In the editor toolbar, click View > Source.  
  3. Once in source view,  add the following code:
<div if="user.groups['Administrators']">Sample</div>
  1. Have administrators visit the page and verify they see the word "Sample."  
  2. Repeat the same steps for the Editors group.

Step 3: Set up your conditional classes

Once you have tested the above code with the groups you have set up, create the custom conditional blocks in the editor for authors to use:

  1. Navigate to Site toolsControl panel > System Settings >Editor.
  2. Copy the following code into the Set editor configuration text field:
CKEDITOR.editorConfig = function( config )
config.stylesSet.push({ name : 'Administrators Conditional Block', element : 'div', wrap:true, attributes : { 'class' : 'mt-style-conditional', 'if' : 'user.groups["Administrators"]'} });
  1. Replace the highlighted items above with your div code:
  • Administrators Conditional Block
    = provide a name that will be easy for your authors to understand and select so they know the user base that the condition applies to.
  • user.groups["Administrators"]
     = replace with the conditional block you want to use.
  1. The editor settings (minus any other code that may be present) should look something like this:

Image of the editor configuration dialog with conditional block code

  1. Click Save
  2. Open a page in Edit mode and verify the custom conditional block shows up in the Styles menu. 

Image of a custom conditional block in the editor

  1. Write any text on the page.
  2. Highlight the text and apply the custom conditional block.

To exit out of a block click SHIFT+ENTER. 

  1. Save the page.
  2. Verify content is only seen by intended users.

Text in a custom conditional block looks the same as any other text. There is no special or formatting associated with custom conditional text blocks. To view the boundaries of the custom block, view the page in Source mode. 


Adding more than one group to a conditional block

From time to time, there will be a need for more than one group to be able to see the same content. With our conditional content statements, this has become even easier.

Use the OR statement

For example, by adding the OR parameter (double straight bars ||) to your statement, members of the Administrators group or the Editors group will be able to see the content within that specific statement. 

<div if="user.groups['Administrators'] || user.groups['Editors']">Sample</div>
Use the AND statement

By adding the AND parameter (double ampersands &&) to your statement, members of the Administrators group and the Editors group will be able to see the content within that specific statement. 

<div if="user.groups['Administrators'] && user.groups['Editors']">Sample</div>


What's next?

Learn how to create custom content templates to use for text styling. 

  • Was this article helpful?