<p>You'll need to do something like this. <code>entry</code> is a How to videos entry.</p>
<pre><code>{% set relatedProducts = entry.productsEntryField.all() %}

{% if relatedProducts|length %}
    {% for product in relatedProducts %}
        &lt;a href=&quot;{{ product.url }}&quot;&gt;Click here to view&lt;/a&gt;
    {% endfor %}
{% endif %}
</code></pre>
<p>The <a href="https://craftcms.com/docs/3.x/entries-fields.html#templating" rel="nofollow noreferrer">Craft docs on Entries Fields</a> has more info.</p>

CC BY-SA 4.0
2020-10-13T06:12:29.327Z
2020-10-13T06:12:29.327Z
Simon Kuran
<p>I have a section type <strong>Structure</strong> called How to videos, in which I have field type <strong>Entries</strong>.</p>
<p>Now, when I select &quot;Products&quot; in the field type 'Entries'. I only want the selected Entries Products to show text &quot;Click here to view&quot;. If there is no entry added in entries fields it should not show text &quot;Click here to view&quot;.</p>
<p>How can I template the Entries field?</p>

<craft3>
Entries field templating only when entry is added
# Entries field templating only when entry is added

(Asked by: username_0 on 2020-10-12)

I have a section type **Structure** called How to videos, in which I have field type **Entries**.

Now, when I select "Products" in the field type 'Entries'. I only want the selected Entries Products to show text "Click here to view". If there is no entry added in entries fields it should not show text "Click here to view".

How can I template the Entries field?

**Tags:** craft3


---

## 1 answers

### Answer by username_1 on 2020-10-13. Score: 1

You'll need to do something like this. entry is a How to videos entry.
{% set relatedProducts = entry.productsEntryField.all() %}

{% if relatedProducts|length %}
    {% for product in relatedProducts %}
        Click here to view
    {% endfor %}
{% endif %}

The Craft docs on Entries Fields has more info.


---

