Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-13T06:12:29.327Z
Answers.LastActivityDate: 2020-10-13T06:12:29.327Z
Answers.UserDisplayName: Simon Kuran
Body: <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>
  
Tags: <craft3>
Title: Entries field templating only when entry is added
ThreadText: # 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 %}
          <a href="{{ product.url }}">Click here to view</a>
      {% endfor %}
  {% endif %}
  
  ```
  
  The [Craft docs on Entries Fields](https://craftcms.com/docs/3.x/entries-fields.html#templating) has more info.
  
  
  ---
  
  