Snippet conditions are condition tags that you can apply to content within snippets. With snippet conditions, you can separate certain snippet content so that it displays in some places but not in others. This allows you to use one snippet for many purposes, rather than having to create multiple snippets. Whereas regular conditions are included or excluded at the target level, snippet conditions are included or excluded at the topic or master page level.
Let’s say that you have a table that you use in several topics. Rather than adding that table manually to the topics, you create a snippet and add that snippet to all of the topics. Now suppose that you need a variation of the table in only a couple of the topics that the snippet is in. Simply apply conditions to certain rows in a snippet’s table and exclude them in the topic properties that you do not want the content to display in.
How to set it up:
To set this up we will need to create a couple of topics, a couple of conditions, and a snippet, and then put them together.
Creating the project and topics:
- Create a new Flare project using the “Empty” template and select WebHelp as the target type.
- Press [ctrl]+[t] to create a topic and name it Letters. Press [ctrl]+[t] again to create a second topics and name it Numbers.
- Open the Master TOC (View > Open Master TOC) and add these two topics to it by dragging them into it.
- Save All
- Go to the Project Organizer and open the Conditional Text folder
- Double-click to open “Default” in the Conditional TagSet Editor
- At this point you can create two new conditions or rename the existing ones, since they are not used in this project. Either create or rename the existing conditions to “Letters” and “Numbers”. If you want select new colors for them.
- Save All
Creating a snippet and adding it to each topic:
- Create a snippet: Project > Add Snippet…
- In the snippet delete everything and add a table with at least two rows and content in each one.
- In the block bar, right-click on a table row (tr) and select Conditions…
- Apply the conditional tag “Letters” to the rows with letters and the conditional tag “Numbers” to the rows with numbers. If you have condtional indicators turned ‘on’ (View > Show > Show Conditional Indicators) you should see the table appear in the editor like this:
- Now just open the two topics (“Letters” and “Numbers”) in the editor and add the snippet to each one: Insert > Snippet…
Setting the Snippet Condition on each topic:
- In the Content Explorer, right-click on the “Numbers” topic and select Properties…
- In the Properties dialog, click the Snippet Conditions tab and set the Default.Letters tag to Exclude.
- Now do the same thing for the “Letters” topic, but this time you will be excluding the Default.Numbers tag.
- Save All
- Open each topic in the editor. Notice that the corresponding rows are gone from the editor. Note: If your table seems to have a background color, remember that we turned ‘on’ the conditional tag indicators in a previous step, just turn them ‘off’ again (View > Show > Show Conditional Indicators).
- Build and view the output to see that the content is removed appropriately.
For more information on snippet conditions go to Flare’s Online Help: http://madcap.us/j6COY9
To download the sample project, click here: