Conditional Paragraph

Top  Print this topic

Conditional Paragraphs are used to display entire paragraphs conditionally based upon a test of your data source.  You can set up as many conditions as you would like to customize what information is displayed for specific values that might reside in your data source.  These elements are incredibly useful for displaying entire paragraphs of content depending on your data.

 

In the example used below, you can notice that a Conditional Paragraph is used to display a table summary only if the value for the show-table attribute in the data source is "true".  This will tell the template whether or not to display the table in the output.  A fallback paragraph is used to display a message if the condition is not met.

 

cond_para_intro

Figure 1:  A Conditional Paragraph is used to display a transaction table according to a test on a data source.

Usage

First you will need to select Insert from the Side Menu. You can then choose Dynamic Element and select Conditional Paragraph from the resulting dialog.  In the Conditional Paragraph dialog you will need to add your conditions accordingly.  You should be aware that you can add as many conditions as you would like to accommodate all of your needed possibilities.

 

When working with conditions, you can choose to include a fallback section if no condition is satisfied.  If you unselect this check box, nothing will be displayed in your output when no condition is met.

 

cond_para_menu

Figure 2:  The Conditional Paragraph dialog allows easy configuration of conditions.

Building Your Conditions

You will now need to select Add new condition in order to add a condition. Upon selecting this option, you will launch the Edit Expression Dialog.  You will need to use this dialog to build your conditional expression.  In this example, the show-table attribute is selected and the '=' operator is used to test for when this value is "true".  When you are happy with your expression, select Apply.

 

cond_para_expression

Figure 3:  A conditional expression is built using the Edit Expression Dialog.  

 

You can repeat this step to add as many conditions as you would like.  You will be adding your content in the Design Surface after you complete this setup.  When you are content with your conditions, select Insert.

Adding Your Content

When you insert your Conditional Paragraph element, you will notice the section will be highlighted in purple and will contain placeholder text for every condition you have configured.  You will now need to replace this placeholder text to add your desired content to be displayed if this condition is met.  In this example, we have replaced the placeholder text with a title paragraph and the table content and added a message "No table view specified" as the fallback section.  Remember, this paragraph will only be displayed if the show-table attribute value is "true".

 

Additionally, you can delete a condition by right clicking on that condition and from the Application Bar, selecting Delete.

 

cond_para_placeholder

Figure 4:  Placeholder text is displayed for each condition including the fallback section.

 

cond_para_content

Figure 5:  Content is added into the condition.

 

When you are satisfied with the added content in your Conditional Paragraph section, you should use the document view menu in the Status Bar to Preview your results.  This will allow you to test the behavior of this Dynamic Element.  You can see in Figure 5 the results from this example using the Print Preview option.  As you can see, the show-table value is "true" and consequentially the Conditional Paragraph section for the table is displayed and not the fallback section.

 

cond_para_output

Figure 6:  The condition is met to display the table paragraph.