Skip to main content
NiCE KnowledgeKnowledge
NiCE Knowledge Success Center

Version indicator with DekiScript

Applies to:
All versions
Role required:
Draft Contributor
Create a custom template to indicate which products an article applies to.

Version indicators can help your customers identify the correct documentation they need, and help unsure users figure out which documentation they should read.

Other reasons to use version indicators:  

  • Your team can deprecate an old version of your product, or features that no longer apply.
  • You can encourage customers to upgrade to a new product.
  • Support agents can easily determine product support flows and guidance.

Prerequisite

Admin user role

How to add a version indicator

To create a version indicator template:

  1. Go to Site tools > Dashboard > Site Administration > Template Directory > Template:Custom > Views.
    Or append /Template:Custom/Views to your site URL.
  2. Click New.
  3. Enter a title for your template.
  4. Save.

Add DekiScript code

  1. On the editor toolbar click Styles > DekiScript.
  2. Paste the following DekiScript code into the box:
var version = $version ?? "default";

<div class="version-indicator">
  <span class="version-text">"This article applies to:"</span>
  if (!version || version == "" || version =="V1")
  {
      <span class="version-tag version-V1">
          <a class="F1 version-reference-link" href="#">"Only Version 1"</a>
      </span>
  }
  if (version == "V2")
  {        
      <span class="version-tag version-V2">
          <a class="F1 version-reference-link" href="#">"Only Version 2"</a>
      </span>
  }
  if (version == "both")
  {
      <span class="version-tag version-both">
          <a class="F1 version-reference-link" href="#">"Version 1 and Version 2"</a>
      </span>
  }
</div>

Add CSS code

  1. In the Editor toolbar, click Styles > CSS.
  2. Paste the following CSS code into the box.
  3. Click Save.
.version-indicator {
   padding:4px;
   background:#efefef;
   overflow:hidden;
   font-size:11px;
   border:1px solid #ccc;
   border-radius:3px;
}
.version-indicator span {
   float:left;
   display:block;
   margin-right:20px;
}
.version-indicator .version-text {
   font-weight:bold;
}

Edit your DekiScript code

To edit the code for your product, replace V1 and V2 in the DekiScript with versions of your product.

To add more versions, paste the following snippet at the end of the code before the </div> tag:

if (version == "V3")
{
<span class="version-tag version-V3">
<a class="F1 version-reference-link" href="#">"Only Version 3"</a>
</span>
}

Link to a document (optional)

To link versions to a document that explains, for example, which version a customer is using, replace the # (of the href attribute) with the path to that document.

The href attribute would look like the following: /Documentation/User_Guide/What_version_of_MindTouch_am_I_using%3F

Add your template to a page

Now that you have created the template, you must add another piece of DekiScript code to your page to surface the version indicator.

  1. Open your page in Edit mode.
  2. Place your cursor at the top of the page. 
  3. In the Editor toolbar, click Styles > DekiScript.
  4. Paste the following code in the box:
template("Custom/Views/Template_Title", {version:"V1"});
  1.  Replace Template_Title with the title of your template. Make sure to use an underscore (_) instead of a space.
  2.  Replace V1 with the version to which the document applies. Make sure the name of the version has quotation marks around it. Two quotation marks by themselves ("") refer to "Only Version 1," while "both" refers to "Version 1 and Version 2."
  • Was this article helpful?