Skip to main content
MindTouch Success Center

Create custom conditional text blocks

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. While conditional content will be displayed to the respective users, this content is not searchable within MindTouch.

  1. Create or modify user groups to use in your conditional text blocks.

    If your groups are synchronized from an external authentication provider, then you do not need to recreate them to set up conditional text blocks.
  2. Create a new page to test your conditional classes.
  3. From the Editor toolbar on your test page, select </> HTML to toggle to source view and add the following code, replacing 'Administrators' with the user group you want to target:
    <div if="user.groups['Administrators']">Sample</div>
  4. Save and access the test page with an account that is assigned the user group you target in the DekiScript.
  5. Verify you see the word "Sample."
  6. Navigate to Site toolsControl panel > System SettingsEditor.
  7. 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"]'} });
  8. 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.
  9. Click Save
  10. Open a page in Edit mode and verify the custom conditional block appears in the Styles menu of the Editor toolbar. 
  11. Highlight any text and click the conditional block name from the Style menu to apply it.
  12. Save the page and 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.

Add more than one group to a conditional block

Use conditional content statements for more than one group to be able to see the same content.

Use the OR statement

Include the OR parameter (double straight bars ||) to your statement. For example, members of the Administrators group or the Editors group will be able to see the conditional content with this code:

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

Use the AND statement

Include the AND parameter (double ampersands &&) to your statement. For example, members of the Administrators group and the Editors group will be able to see the conditional content with this code:

<div if="user.groups['Administrators'] && user.groups['Editors']">Sample</div>
  • Was this article helpful?