- Theme Engine
- Design Principles
- Templates
- EVML Reference
- Output
- Comments
- Operators
- Statements and Declarations
- Built-in Functions
- Built-in Objects
- Account
- Address
- Array
- Boolean
- Branch
- Cart
- CartLine
- Category
- CategoryCollection
- CategoryFilter
- CategoryFilterCollection
- CategoryFilterOption
- CategorySearch
- Collection
- Color
- Contact
- Currency
- Date
- Discount
- Dom
- Event
- EventCollection
- EventSlot
- Image
- Layout
- Locale
- Money
- Number
- Object
- Page
- PageCollection
- PageSearch
- PageSharer
- Pagination
- Postage
- Price
- PriceDiscount
- Product
- ProductCollection
- ProductCustomisation
- ProductDownload
- ProductMedia
- ProductMediaFrame
- ProductPrice
- ProductSearch
- ProductSpecification
- ProductSpecificationValue
- ProductVariation
- ProductVariationOption
- RecentlyViewed
- RegExp
- Request
- Review
- ReviewCollection
- Search
- SearchCollection
- SearchResult
- String
- Tag
- Template
- Url
- Website
- EV Tags
- CSS Pre-processor
- Ajax API
Listing downloads for a product
A product may have any number of downloads. Many merchants like to offer PDF downloads such as instruction manuals, installation instructions or care guides.
All downloads for a product are accessible via the Product.downloads()
method which returns
an Array of ProductDownload objects.
<ul>
<?ev for (var download of product.downloads()) { ?>
<li>
<a href="{{ download.url }}" target="_blank">
{{ download.title }}
<br>
{{ download.filename }}
<br>
{{ download.size }}
</a>
</li>
<?ev } ?>
</ul>
Handling missing files
In a perfect World things wouldn't go missing. Sadly, they do. Downloads might have been deleted or imported incorrectly.
You can determine if a product download's file exists with the ProductDownload.exists()
method.
<ul>
<?ev
for (var download of product.downloads()) {
// Skip missing downloads
if (!download.exists()) {
continue;
}
?>
<li>
<a href="{{ download.url }}" target="_blank">
{{ download.title }}
<br>
{{ download.filename }}
<br>
{{ download.size }}
</a>
</li>
<?ev } ?>
</ul>
Learn more about ProductDownload objects