How to assign a URL to only one slide in a template using Matrix? So I am using the matrix field to enable uploading of images onto a slideshow for the homepage section. My goal is to have one of the images link to another URL when you click on it. Basic stuff when using plain HTML, but I have it setup like this in Twig:

{% for block in entry.information %}
{% if block.type == "images" %}
   {% set image = block.image.first() %}
       {% if image %}
            &lt;a href={{ block.anchor | cacheBuster }} target="_blank"&gt;
                &lt;img class="slideshow" src={{ image.url | cacheBuster }} alt={{ image.title }}&gt;
            &lt;/a&gt;
        {% endif %}
    {% endif %}
{% endfor %}


This code runs fine and my slideshow images are all displayed using just one loop.

The problem is, all my slides are having an anchor field activated. I only want one of the slides to have a link to a URL, however, in the future I may want to add links to other slides so I need something that is also dynamic enough to support this.

My whole entire approach may be wrong and I might need to use a completely different approach... assistance is greatly appreciated.
Try something like:

{% for block in entry.information %}
{% if block.type == "images" %}
    {% set image = block.image.first() %}
        {% if image %}
            {% if block.anchor |length %}
            &lt;a href={{ block.anchor | cacheBuster }} target="_blank"&gt;
                &lt;img class="slideshow" src={{ image.url | cacheBuster }} alt={{ image.title }}&gt;
            &lt;/a&gt;
            {% else %}
            &lt;img class="slideshow" src={{ image.url | cacheBuster }} alt={{ image.title }}&gt;
            {% endif %}
        {% endif %}
    {% endif %}
{% endfor %}


So that only if the block.anchor field has something in it do you generate the link &amp; the image. Otherwise, you just generate the image.