Conditional content

This page delves into details related to template-based thumbnails. Look here for more general information on templates.


What is a conditional content?

Conditional content is the ability to allow or block content declared in a template. Conditional content is resolved during a thumbnail page generation step, and depends on the value of some condition.

In order to use conditions, a special keyword must be used, $(IF, condition=" <expression> ") <conditional content> $(ENDIF).


A simple scenario

Suppose you want to add navigation links across the pages of your thumbnail, to allow your audience to click through the pages back and forth. Regardless conditional content for the moment, you'll easily come up with a simple navigation bar like this :

<a href="$(PREVIOUSPAGE)">Prev</a>[ Page $(PAGE) / $(PAGECOUNT) ]
<a href="$(NEXTPAGE)">Next</a>

But there is something wrong about it, those tags show a Previous link even in the first page, although by definition there can't be any previous page on the first page! By analogy, those tags show a Next link even in the last page, although a last page is a last page!

In order to solve this, software products typically implement the behaviour internally and don't let users take control over it. AVS grants you, however, full control over it. This is because the template should hold the entire application logic of thumbnails, and according to the author of the product, there cannot be any compromise about this if a product intends to empower people and let them create really outstanding thumbnails on their own.

Conditional content comes handy at this point. Using a formula, you can tell that the Previous link should be added only if the page being generated is not the first one. A simple html-way to achieve that is to encompass the Previous link-related html tags within a condition like this :

$(IF, "$(PAGE) > 1") <conditional content> $(ENDIF)

If we add the html tags to it, it goes :

$(IF, "$(PAGE) > 1")<a href="$(PREVIOUSPAGE)">Prev</a>$(ENDIF)

Adding an equivalent condition for the last page, it goes :

$(IF, "$(PAGE) > 1")<a href="$(PREVIOUSPAGE)">Prev</a>$(ENDIF)
[ Page $(PAGE) / $(PAGECOUNT) ]
$(IF, "$(PAGE) < $(PAGECOUNT)")<a href="$(NEXTPAGE)">Next</a>$(ENDIF)


Regarding expressions, the following operators are available :

  • +, -, *, / (4 primary operators)
  • <, >, =, != (comparison operators)
  • % (modulo operator), see conditional formatting for a sample
  • AND, OR (logical operators)
  • (, ) (parenthesis and grouping operators)

And of course, all keywords are available, as well numerical and string litterals.


Other scenarios

The simple scenario, was quite illustrative of the feature, is only one and it has to do with typical requirements over an navigation bar. It's just as easy to apply conditional content to shot html blocks of tags themselves, and a scenario could be : allow the given shot to be displayed only if its frame interval in the video is greater than a given threshold. In other words, this scenario allows to create partial views of thumbnails that reflect for instance all sequences where a given actor appears.

There can be many more scenarios. Once you've got one in mind, you have to translate the requirements into a combination of expressions and keywords. That is usually not a tough work. However, for complex scenarios, the use of complex and lengthy expressions is a given.

Make sure to distinguish conditional content and conditional formatting. Conditional content allows or blocks content, while conditional formatting adapts formatting styles according to predefined rules.