"if/endif" Statements

Format template have the ability to interpret "IF" statements to determine whether or not to display certain fields. For example, a DVD includes fields such as the actors names, and the director's name. However, a BOOK, or MUSIC does not include those fields. In addition, you may wish to display 4 customer reviews, however, some records may only have 3 customer reviews available. Associate Engine is able to interpret "IF" statements to handle the differences in the different types of products.

The "IF" statement can be in either of the following two simple formats:

{if CONDITION} TEXT {endif}

<!--if CONDITION--> TEXT <!--endif-->

The TEXT can be any text or HTML that you want included when the CONDITION is true. Use the <!--if ...--> version (an HTML comment) if your HTML editor does not let you type arbitrary text where text is not allowed. For example, you might want to include a table row only if there is a list price, such as: (optional indentation is shown for clarity only)

The <!--if details.listprice--> specifies the condition. The <!--endif--> specifies the end of the text. Everything in between is the text to include if the condition is true.

"if" statements can be nested, that is, TEXT can contain an "if" statement. The following includes a "List Price" row if there is a list price and includes a "You Save" row only if there is a list price and the savings (i.e.: difference between list price and sales price) is non-zero: (optional indentation is shown for clarity only)

Notes: the following DVD example includes "Starring" and "Directed" fields. However, in the subsequent examples (music and book) these two fields are automatically excluded as they are not relevant to music and books. Also, the "Features" include 4 entries for this DVD (see also the music example where only 1 entry is available, and the book example where no Features are available).

Notes: the following sample automatically excludes the "Starring" and "Directed" fields seen in the DVD example. The "Features" for this particular CD only has 1 entry at Amazon.com and as such the list has been automatically adjusted to show only bullet-point.

Notes: the following sample automatically excludes the "Starring" and "Directed" fields seen in the DVD example. Also, since Amazon.com does not list any features for this book, the "if" statement excludes showing the "Features" title and bullet list as seen in the DVD and music examples above.