Technical Writing, Documentation, and Digital Publications

Blog

General thoughts on technical communication. Tricks, Best Practices, and Overengineered Solutions for Madcap Flare

Creating 'AND' Statements for Flare Conditions

Condition tags in Madcap Flare are one of your best friends when it comes to taking content and reusing across multiple targets. However, when used in the standard way, conditions have a limitation that two conditionals marked to a piece of content will act as an 'OR' statement. What if you want to use conditional text as an 'AND', where the content is not shown unless both conditions are met?

Say you have the following content:

<p MadCap:conditions="Primary.ConditionA,Primary.ConditionB">Foobar module must be available.</p>

The <p> shown here has both conditions, which means that if either ConditionA OR ConditionB is set to Include (or not set to either Include or Exclude) in a target, it will be included in the published topic.

What if you want to have the <p> above only publish if both ConditionA AND ConditionB are set to Include? To do this we will need to wrap the content in two different condition statements.

 This could be done by wrapping the <p> in a <div> like so:

<div MadCap:conditions="Primary.ConditionA"><p MadCap:conditions="Primary.ConditionB">Foobar module must be available.</p></div>

This works for block elements. Now if ConditionA is set to Include and ConditionB is set to Exclude, you will get an empty <div> in the output. If the Include/Exclude is the other way, none of the content will be included.

What if the content you want to conditionalize is inline, like in this case?

<p>Foobar module requires sub-module A and B.</p>

This is trickier because we want A and B to use the ConditionA and ConditionB tags respectively, but the 'and' in the sentence should only appear if both conditions are Included. To do this we can add our nested tags inline:

<p MadCap:conditions="Primary.ConditionA,Primary.ConditionA">Foobar module requires sub-module <MadCap:conditionalText MadCap:conditions="Primary.ConditionA">A</MadCap:conditionalText><MadCap:conditionalText MadCap:conditions="Primary.ConditionB"><MadCap:conditionalText MadCap:conditions="Primary.ConditionA"> and </MadCap:conditionalText>B</MadCap:conditionalText>.</p>

This gives us the results we want: four different possibilities for the sentence:

  • Exclude A / Exclude B: Nothing included in publish.
  • Include A / Exclude B: Foobar module requires sub-module A.
  • Exclude A / Include B: Foobar module requires sub-module B.
  • Include A / Include B: Foobar module requires sub-module A and B.

Note: This tip uses html examples, but the same effect can be done in the XML editor. It's just much harder to see what's going on with your conditions (and harder to screenshot).