Introduction
This tutorial shows how to use velocity code and conditional statements within your catalog templates to display an items multimedia. This velocity code example is intended to be used with the catalog templates:
...
Here we have looped through the item to see if there are any multimedia files with the code "image". If the condition is true the following code is output:
Code Block | ||||
---|---|---|---|---|
| ||||
<a href="$item.getDefaultMultimedia('Image').getViewUrl()" title="$item.getDescription()"> <img src="$baseThumbnailUrl$item.getDefaultMultimedia('Image').getThumbnail(240)" alt="$item.getDescription()" width="240" height="240" /> </a> |
...
If there is no multimedia uploaded to the item with the code "Image" then the #else condition is true and the following code is output:
Code Block | ||||
---|---|---|---|---|
| ||||
<img src="default.jpg" alt="Image coming soon"/> |
...