One of the nice features of MadCap Flare is the ability to use conditions to create text that shows in one target and is left out in another target. Due to the way that the conditions work, technical writers (or technical authors, depending on your location in the world) often have a hard time to make text behave the way they like.
One of the hurdles that you come across is that the logic behind the conditions uses the logical ‘or’ to determine if text is shown. Simply put, if A is true, or B is true, or both A and B are true, the text is shown.
To help you understand, here are the logical conditions and what they mean:
or: When A is set, or B is set, or both A and B are set, show the text.
and: Only when both A and B are set, show the text.
In the Flare target you have the option of changing the formula using the advanced formula editor, so you can change ‘or’ to ‘and’ for that particular output, but what if you want an ‘and’ for a particular line of text while keeping an ‘or’ for the rest of the page?
That level of detail goes beyond what you can control from your target. The answer is to use nested conditions when you need an ‘and’ and to use multiple conditions in one condition statement when you want ‘or’.
Use nested conditions to force both conditions to be true.
An example:
Let’s say you have a text that has a target for a website and a target for a document. You wish to put a line in the introduction that says ‘On this webpage you will find information about …’ for the website and ‘In this document you will find information about …’ for the PDF document.
Also, the subject of the document has two particular flavors: apples and pears.
So, in total there are two websites and two PDF documents, resulting in four possible sentences. Following the principles for translation, you don’t want to chop up your line into small bits, so you create four sentences:
In this document you will find information about apples.
In this document you will find information about pears.
On this website you will find information about apples.
On this website you will find information about pears.
Now, here’s the problem. If you apply the conditions ‘document’ and ‘apples’ to the first line, Flare will create a condition like this:
<MadCap:conditions=”Target.document,Subject.apples”>In this document you will find information about apples.</Madcap:conditions>
For the second line it is a similar story, but with conditions ‘document’ and ‘pears’ instead, so Flare will create the following condition:
<MadCap:conditions=”Target.document,Subject.pears”>In this document you will find information about pears.</Madcap:conditions>
If the Flare target has the condition Target set to ‘document’ both lines will be shown, because the condition ‘document’ is now true. It ignores whether the other condition is set to ‘apples’ or ‘pears’. This is not what we want, so we need to change the conditions somehow to get Flare to respect both conditions.
To accomplish this, we need to nest the conditions (place one condition within the tags of the other condition), as shown in the example below:
<MadCap:conditions=”Target.document”><MadCap:conditions=”Subject.apples”>In this document you will find information about apples.</MadCap:conditions><MadCap:conditions=”Subject.pears”>In this document you will find information about pears.</MadCap:conditions></MadCap:conditions>
As you can see, it will first check whether the ‘document’ condition is met, if it is, it will then check, whether ‘apples’ condition is true or ‘pears’ condition is true, and show the sentence(s) for which this is true.
Now the line for a document about apples is only shown if the Target is ‘document’ and then if the Subject is ‘apples’.
A second set is created for the websites:
<MadCap:conditions=”Target.website”><MadCap:conditions=”Subject.apples”>On this website you will find information about apples.</MadCap:conditions><MadCap:conditions=”Subject.pears”>On this website you will find information about pears.</MadCap:conditions></MadCap:conditions>
By nesting the conditions, both of them need to be selected for that particular target to show the line in your documentation.
Hopefully, MadCap will one day put this in Flare, so we don’t have to write this code manually, but we can simply select it through the interface. Until then, use this knowledge to your advantage.