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:

  1. Create a new Flare project using the “Empty” template and select WebHelp as the target type.
  2. Press [ctrl]+[t] to create a topic and name it Letters.  Press [ctrl]+[t] again to create a second topics and name it Numbers.
  3. Open the Master TOC (View > Open Master TOC) and add these two topics to it by dragging them into it.
  4. Save All
    Content Explorer and TOC

Creating conditions:

  1. Go to the Project Organizer and open the Conditional Text folder
  2. Double-click to open “Default” in the Conditional TagSet Editor
  3. 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.
  4. Save All
    Conditional Tags

 Creating a snippet and adding it to each topic: 

  1. Create a snippet: Project > Add Snippet…
  2. In the snippet delete everything and add a table with at least two rows and content in each one.
  3. In the block bar, right-click on a table row (tr) and select Conditions…
    Apply Condtions
  4. 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:
    Table with Condtions
  5. 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:

  1. In the Content Explorer, right-click on the “Numbers” topic and select Properties…
  2. In the Properties dialog, click the Snippet Conditions tab and set the Default.Letters tag to Exclude.
    Exclude Conditional Tag
  3. Now do the same thing for the “Letters” topic, but this time you will be excluding the Default.Numbers tag.
  4. Save All
  5. 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).
  6. 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: Snippet Condition Sample Project

About The Author

Jose Sermeno

About Jose Sermeno

With over 10 years of experience in the software industry, Mr. Sermeno brings a wealth of knowledge and expertise to the product evangelist team, helping introduce new users to everything MadCap Software. In his spare time, Jose is the Project Director for San Diego City Robotics, the San Diego community college systems robotics program, and enjoys working in software design and open source hardware development. Prior to joining MadCap in late 2010, Jose ran a Drupal development shop, and was an application manager for Temple University Health System.

Last Modified: February 15, 2012

This entry was posted in MadCap Flare, MadPak, Tech Comm, Tips & Tricks. Bookmark the permalink.

Have Something to Say?

Your email address will not be published. Required fields are marked *