<p>Assuming the field where your client can select the download is an asset field, you can use the following:</p>

<pre><code>{% elseif block.type == "bladeBrochure" %}
    {% set download = block.download.first() %}
    {% if download %}
        &lt;a href="{{ download.url }}"&gt;Click me to download&lt;/a&gt;
    {% endif %}
</code></pre>

<p>Replacing <code>block.download</code> with the name of your field.</p>

CC BY-SA 3.0
2014-10-09T10:44:47.257Z
2014-10-09T10:44:47.257Z
Jamie Wade
<p>I'm assuming that your PDF field is an assets field? If so, it works exactly the same way as images, and you can output it using something like this:</p>

<pre><code>{% for block in entry.matrixFieldHandle %}
    {% set pdf = block.pdfFieldHandle.first() %}
    &lt;a href="{{pdf.getUrl}}"&gt;Text&lt;/a&gt;
{% endfor %}`
</code></pre>

CC BY-SA 3.0
2014-10-09T20:27:54.137Z
Thanks for editing Brandon; for some reason the 4-space indent just wasn't turning it into code earlier!
darylknight
CC BY-SA 3.0
2014-10-09T10:42:58.433Z
2014-10-09T17:06:47.260Z
2014-10-09T17:06:47.260Z
darylknight
<p>I have a Matrix field with Image, Caption, and PDF sub-fields. I can output the Image and Caption fine, but am having no luck with the PDF file.</p>

<p>Here is the code:</p>

<pre class="lang-twig prettyprint-override"><code>{% for block in entry.seriesInformation %}
    {% if block.type == "bladeImage" %}

        {% set image = block.image.first() %}

        {% if image %}
            &lt;img src="{{ image.getUrl('bladesdetail') }}" width="{{ image.getWidth('bladesdetail') }}" height="{{ image.getHeight('bladesdetail') }}" alt="{{ image.title }}"&gt;
        {% endif %}

    {% elseif block.type == "caption" %}

        {{ block.caption }}

    {% elseif block.type == "bladeBrochure" %}

        &lt;p&gt;&lt;a href="{{ bladeBrochure.url }}"&gt;Download &amp;rarr;&lt;/a&gt;&lt;/p&gt;

    {% endif %}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2014-10-09T17:06:05.853Z
Hi Brett, welcome to the Craft Stack Exchange site! I’ve edited your question a bit to make it more clear, and removed your second question about creating a Blog. Please post that as a separate question so it can have its own direct set of answers.
Brandon Kelly
<matrix><blocks>
How do I output a file’s URL in a Matrix field?
# How do I output a file’s URL in a Matrix field?

(Asked by: username_0 on 2014-10-09)

I have a Matrix field with Image, Caption, and PDF sub-fields. I can output the Image and Caption fine, but am having no luck with the PDF file.
Here is the code:
{% for block in entry.seriesInformation %}
    {% if block.type == "bladeImage" %}

        {% set image = block.image.first() %}

        {% if image %}
            
        {% endif %}

    {% elseif block.type == "caption" %}

        {{ block.caption }}

    {% elseif block.type == "bladeBrochure" %}

        Download →

    {% endif %}
{% endfor %}

**Tags:** matrix, blocks

> **Comments:**
> **username_1**: Hi Brett, welcome to the Craft Stack Exchange site! I’ve edited your question a bit to make it more clear, and removed your second question about creating a Blog. Please post that as a separate question so it can have its own direct set of answers.  

---

## 2 answers

### Answer by username_2 on 2014-10-09. Score: 6

Assuming the field where your client can select the download is an asset field, you can use the following:
{% elseif block.type == "bladeBrochure" %}
    {% set download = block.download.first() %}
    {% if download %}
        Click me to download
    {% endif %}

Replacing block.download with the name of your field.


---

### Answer by username_3 on 2014-10-09. Score: 5

I'm assuming that your PDF field is an assets field? If so, it works exactly the same way as images, and you can output it using something like this:
{% for block in entry.matrixFieldHandle %}
    {% set pdf = block.pdfFieldHandle.first() %}
    Text
{% endfor %}`

> **Comments:**
> **username_3**: Thanks for editing Brandon; for some reason the 4-space indent just wasn't turning it into code earlier!  

---

