$39

Digital Download

Documentation  •  Changelog

Documentation

Displaying a Link

Manual vs. Automatic Token Generation

When automatically generating a token, it'll create a new token every time the link is rendered. When you manually generate a token, you can store it to be used again later.

The main difference between generating a token manually or automatically is in which parameters you provide to the function.

Manual Token Generation

If you are generating a token separately, you'd use it like this:

url(token)

{% set token = craft.digitalDownload.createToken(file, options) %}

<a href="{{ craft.digitalDownload.url(token) }}">{{ file.title }}</a>

link(token, label = "Download")

{% set token = craft.digitalDownload.createToken(file, options) %}

{{ craft.digitalDownload.link(token, file.title) }}

When you bypass manual token creation, you can pass the AssetFileModel directly into the url or link methods. In these cases, you can also provide an array of options, which govern how and when the file can be accessed.

Automatic Token Generation

If you are not generating a token separately, you'd use it like this:

url(file, options = [])

<a href="{{ craft.digitalDownload.url(file, options) }}">{{ file.title }}</a>

link(file, options = [], label = "Download")

{{ craft.digitalDownload.link(file, options, file.title) }}