Answers.Body: <p>Thank you @Robin :) but I managed to do it myself.
  It works nicely :)</p>
  
  <pre><code>{% set entries = craft.entries.section("galeria").all() %}
  
  {% for entry in entries %}
      {% for block in entry.galeriaMatrix.all() %}
          {% switch block.type %}
              {% case "itemsGaleria" %}
                  {% for image in block.fotografia %}
                      &lt;img src="{{image.url}}" alt="{{image.title}}" /&gt;
                  {% endfor %}
  
                  {{ block.titulo }}
                  {{ block.texto }}
              {% default %}
          {% endswitch %}
      {% endfor %}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-10T20:11:41.460Z
Answers.LastActivityDate: 2019-04-11T02:32:20.950Z
Answers.LastEditDate: 2019-04-11T02:32:20.950Z
Answers.UserDisplayName: André Castro
Body: <p>I'm trying to loop a Matrix field that has one block containing 3 items.</p>
  
  <pre><code>{% for block in entry.galeria.type('itemsGaleria') %}
      {% if block.titulo|length %}
          {{ block.titulo.first }}
      {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>But Craft always throws the error variable entry does not exist.</p>
  
  <p>I read the Matrix section from Craft 3 docs but cannot fix this problem.</p>
  
  <p>Any clues?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-04-10T18:44:28.200Z
Comments.Text: Do you define entry somewhere or are you in an entries template?
Comments.UserDisplayName: Robin Schambach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-04-10T18:55:11.123Z
Comments.Text: I'm in an entries template.
Comments.UserDisplayName: André Castro
Tags: <craft3><matrix><loop>
Title: Matrix Field - variable entry does not exist
ThreadText: # Matrix Field - variable entry does not exist
  
  (Asked by: username_0 on 2019-04-10)
  
  I'm trying to loop a Matrix field that has one block containing 3 items.
  
  ```
  {% for block in entry.galeria.type('itemsGaleria') %}
      {% if block.titulo|length %}
          {{ block.titulo.first }}
      {% endif %}
  {% endfor %}
  
  ```
  
  But Craft always throws the error variable entry does not exist.
  
  I read the Matrix section from Craft 3 docs but cannot fix this problem.
  
  Any clues?
  
  **Tags:** craft3, matrix, loop
  
  > **Comments:**
  > **username_1**: Do you define entry somewhere or are you in an entries template?  
  > **username_0**: I'm in an entries template.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-04-10. Score: 1
  
  Thank you @username_1 :) but I managed to do it myself.
  It works nicely :)
  
  ```
  {% set entries = craft.entries.section("galeria").all() %}
  
  {% for entry in entries %}
      {% for block in entry.galeriaMatrix.all() %}
          {% switch block.type %}
              {% case "itemsGaleria" %}
                  {% for image in block.fotografia %}
                      <img src="{{image.url}}" alt="{{image.title}}" />
                  {% endfor %}
  
                  {{ block.titulo }}
                  {{ block.texto }}
              {% default %}
          {% endswitch %}
      {% endfor %}
  {% endfor %}
  
  ```
  
  
  ---
  
  